code-rag-bench/online-tutorials huggingface dataset:
AutoField – Django Models

12 Feb, 2020
According to documentation, An AutoField is an IntegerField that automatically increments according to available IDs. One usually won’t need to use this directly because a primary key field will automatically be added to your model if you don’t specify otherwise.
By default, Django gives each model the following field:
id = models.AutoField(primary_key=True, **options)
This is an auto-incrementing primary key. Even if the model doesn’t have any field, a default field will be created named as id.
Illustration of AutoField using an Example. Consider a project named geeksforgeeks having an app named geeks.
Refer to the following articles to check how to create a project and an app in Django.
How to Create a Basic Project using MVT in Django?
How to Create an App in Django ?
Enter the following code into models.py file of geeks app.
from django.db import modelsfrom django.db.models import Model# Create your models here.  class GeeksModel(Model):    pass
Add the geeks app to INSTALLED_APPS
# Application definition  INSTALLED_APPS = [    'django.contrib.admin',    'django.contrib.auth',    'django.contrib.contenttypes',    'django.contrib.sessions',    'django.contrib.messages',    'django.contrib.staticfiles',    'geeks',]
Now when we run makemigrations command from the terminal,
Python manage.py makemigrations
A new folder named migrations would be created in geeks directory with a file named 0001_initial.py
# Generated by Django 2.2.5 on 2019-09-25 06:00  from django.db import migrations, models  class Migration(migrations.Migration):      initial = True      dependencies = [    ]      operations = [        migrations.CreateModel(            name ='GeeksModel',            fields =[                ('id',                   models.AutoField(auto_created = True,                  primary_key = True,                  serialize = False,                   verbose_name ='ID'                )),            ],        ),    ]
Thus, an id AutoField that auto increments on every instance of that model is created by default when you run makemigrations on the project. It is a primary key to the table created for the model named GeeksModel.
If we create objects of this empty model from the admin server. we can see id field autoincrementing on every instance created.
Field Options are the arguments given to each field for applying some constraint or imparting a particular characteristic to a particular Field. For example, adding an argument primary_key=True to AutoField will make it primary key for that table in relational database.Here are the option and attributes that an Autofield can use.
NaveenArora
Django-models
Python Django
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
DateTime.ToLongDateString() Method in C#

11 Feb, 2019
This method is used to convert the value of the current DateTime object to its equivalent long date string representation.
Syntax: public string ToLongDateString ();
Return Value: This method returns a string that contains the long date string representation of the current DateTime object.
Below programs illustrate the use of DateTime.ToLongDateString() Method:
Example 1:
// C# program to demonstrate the// DateTime.ToLongDateString()// Methodusing System;using System.Globalization;  class GFG {      // Main Method    public static void Main()    {          // creating object of DateTime        DateTime date = new DateTime(2011, 1,                                1, 4, 0, 15);          // Converting the value of the         // current DateTime object to         // its equivalent long date         // string representation.        // using ToLongDateString() method;        string value = date.ToLongDateString();          // Display the date        Console.WriteLine("String representation"+                        " of date is {0}", value);    }}
String representation of date is Saturday, 01 January 2011

Example 2:
// C# program to demonstrate the// DateTime.ToLongDateString()// Methodusing System;using System.Globalization;  class GFG {      // Main Method    public static void Main()    {          // creating object of DateTime        DateTime date = DateTime.Now;          // Converting the value of the        // current DateTime object to         // its equivalent long date         // string representation.        // using ToLongDateString() method;        string value = date.ToLongDateString();          // Display the date        Console.WriteLine("String representation "+                          "of date is {0}", value);    }}
String representation of date is Monday, 11 February 2019

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tolongdatestring?view=netframework-4.7.2
CSharp DateTime Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Multiple inheritance using interfaces
Differences Between .NET Core and .NET Framework
Extension Method in C#
C# | List Class
HashSet in C# with Examples
C# | .NET Framework (Basic Architecture and Component Stack)
Switch Statement in C#
Lambda Expressions in C#
Partial Classes in C#
Hello World in C#
Merge Pandas DataFrame with a common column

To merge two Pandas DataFrame with common column, use the merge() function and set the ON parameter as the column name.
At first, let us import the pandas library with an alias −
import pandas as pd
Let us create the 1st DataFrame −
dataFrame1 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'],"Units": [100, 150, 110, 80, 110, 90]
   }
)
Next, create the 2nd DataFrame −
dataFrame2 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Mercedes', 'Jaguar'],"Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000]

   }
)
Now, merge the two DataFrames with a column column “Car” −
mergedRes = pd.merge(dataFrame1, dataFrame2, on ='Car')

Following is the complete code −
import pandas as pd

# Create DataFrame1
dataFrame1 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Bentley', 'Jaguar'],"Units": [100, 150, 110, 80, 110, 90]
   }
)

print"DataFrame1 ...\n",dataFrame1

# Create DataFrame2
dataFrame2 = pd.DataFrame(
   {
      "Car": ['BMW', 'Lexus', 'Audi', 'Mustang', 'Mercedes', 'Jaguar'],"Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000]

   }
)

print"\nDataFrame2 ...\n",dataFrame2

# merge DataFrames with common column Car
mergedRes = pd.merge(dataFrame1, dataFrame2, on ='Car')
print"\nMerged data frame with common column...\n", mergedRes
This will produce the following output −
DataFrame1 ...
       Car   Units
0      BMW     100
1    Lexus     150
2     Audi     110
3  Mustang      80
4  Bentley     110
5   Jaguar      90

DataFrame2 ...
        Car   Reg_Price
0       BMW        7000
1     Lexus        1500
2      Audi        5000
3   Mustang        8000
4  Mercedes        9000
5    Jaguar        6000

Merged data frame with common column...
       Car   Units   Reg_Price
0      BMW     100        7000
1    Lexus     150        1500
2     Audi     110        5000
3  Mustang      80        8000
4   Jaguar      90        6000
Python PIL | Image.resize() method

17 Jun, 2021
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.Image.resize() Returns a resized copy of this image. 
Syntax: Image.resize(size, resample=0) Parameters: size – The requested size in pixels, as a 2-tuple: (width, height). resample – An optional resampling filter. This can be one of PIL.Image.NEAREST (use nearest neighbour), PIL.Image.BILINEAR (linear interpolation), PIL.Image.BICUBIC (cubic spline interpolation), or PIL.Image.LANCZOS (a high-quality downsampling filter). If omitted, or if the image has mode “1” or “P”, it is set PIL.Image.NEAREST.Returns type: An Image object. 
Image Used:  
 
Python3
# Importing Image class from PIL modulefrom PIL import Image # Opens a image in RGB modeim = Image.open(r"C:\Users\System-Pc\Desktop\ybear.jpg") # Size of the image in pixels (size of original image)# (This is not mandatory)width, height = im.size # Setting the points for cropped imageleft = 4top = height / 5right = 154bottom = 3 * height / 5 # Cropped image of above dimension# (It will not change original image)im1 = im.crop((left, top, right, bottom))newsize = (300, 300)im1 = im1.resize(newsize)# Shows the image in image viewerim1.show()
Output:  
Another example:Here we use the different newsize value. 
Python3
# Importing Image class from PIL modulefrom PIL import Image # Opens a image in RGB modeim = Image.open(r"C:\Users\System-Pc\Desktop\ybear.jpg") # Size of the image in pixels (size of original image)# (This is not mandatory)width, height = im.size # Setting the points for cropped imageleft = 6top = height / 4right = 174bottom = 3 * height / 4 # Cropped image of above dimension# (It will not change original image)im1 = im.crop((left, top, right, bottom))newsize = (200, 200)im1 = im1.resize(newsize)# Shows the image in image viewerim1.show()
Output:  
 
simranarora5sos
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
HTML | DOM attributes Property - GeeksforGeeks

25 Jul, 2019
The attributes property in HTML DOM returns the group of node attributes specified by NamedNodeMap objects. The NamedNodeMap object represents the collection of attribute objects and can be accessed by index number. The index number starts at 0.
Syntax:
node.attributes
Return Value: It returns the NamedNodeMap object which is the collection of nodes.
Note: In Internet Explorer 8 and earlier versions, the attributes property will return a collection of all possible attributes for an element that can result in higher value than expected.
Example 1:
<!DOCTYPE html><html>    <head>        <title>            HTML DOM attributes Property        </title>    </head>          <body>              <!-- Setting up an image -->        <img id = "GFG" src = "https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-logo.png" >                  <br>        <button onclick = "myGeeks()">            DOM attributes property        </button>                  <p id = "demo"></p>                  <script>            function myGeeks() {                            // It returns the number of nodes            var x = document.getElementById("GFG").attributes.length;                           // Display the number of nodes            document.getElementById("demo").innerHTML = x;         }        </script>    </body></html>                    
Output:
Example 2:
<!DOCTYPE html><html>  <head>    <title>        HTML DOM attributes Property    </title></head>  <body>    <h2>            HTML DOM attributes Property        </h2>      <button id="GFG" onclick="myGeeks()">        Click Here!    </button>      <br>    <br>      <span>            Button element attributes:         </span>      <span id="sudo"></span>      <script>        function myGeeks() {              // It returns the number of nodes                var gfg =                 document.getElementById("GFG").attributes.length;              // Display the number of nodes            document.getElementById("sudo").innerHTML = gfg;        }    </script></body>  </html>
Output:
Supported browsers The browser supported by DOM attributes property are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Apple Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-DOM
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to set the default value for an HTML <select> element ?
How to update Node.js and NPM to next version ?
How to set input type date in dd-mm-yyyy format using HTML ?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Event bubbling vs event capturing in JavaScript?

Event Bubbling − Whenever an event happens on an element, the event handlers will first run on it and then on its parent and finally all the way up to its other ancestors.
Event Capturing − It is the reverse of the event bubbling and here the event starts from the parent element and then to its child element.
Following is the code for event bubbling vs event capturing in JavaScript −
 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 {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 18px;
      font-weight: 500;
      color: blueviolet;
   }
   .outer {
      display: inline-block;
      width: 400px;
      height: 200px;
      font-size: 20px;
      background-color: chartreuse;
   }
   .inner {
      width: 200px;
      height: 100px;
      font-size: 20px;
      background-color: blueviolet;
      text-align: center;
      margin: 20px;
   }
   .tags {
      display: inline-block;
      width: 400px;
      font-weight: bold;
      font-size: 18px;
   }
</style>
</head>
<body>
<h1>Event bubbling vs event capturing</h1>
<div class="outer">
OUTER
<div class="inner">INNER</div>
</div>
<div class="outer">
OUTER
<div class="inner">INNER</div>
</div>
<br />
<div class="tags">Bubbling</div>
<div class="tags">Capturing</div>
<div class="result"></div>
<script>
   let outerDiv = document.querySelectorAll(".outer");
   let innerDiv = document.querySelectorAll(".inner");
   let resEle = document.querySelector(".result");
   outerDiv[0].addEventListener("click", () => {
      resEle.innerHTML += "Outer div has been clicked" + "<br>";
   });
   innerDiv[0].addEventListener("click", () => {
      resEle.innerHTML = "";
      resEle.innerHTML += "Inner div has been clicked" + "<br>";
   });
   outerDiv[1].addEventListener("click",() => {
      resEle.innerHTML = "";
      resEle.innerHTML += "Outer div has been clicked" + "<br>";
   },true);
   innerDiv[1].addEventListener("click",() => {
      resEle.innerHTML += "Inner div has been clicked" + "<br>";
   }, true);
</script>
</body>
</html>
On clicking the inner div having the event bubbling −
On clicking the inner div having the event capturing −
How to order by timestamp in MySQL?

To order by timestamp, use the ORDER BY as in the following syntax −
select *from yourTableName ORDER BY STR_TO_DATE(`yourColumnName`,'%m/%d/%Y%h:%i:%s %p');
Let us first create a table −
mysql> create table DemoTable
   -> (
   -> `timestamp` varchar(100)
   -> );
Query OK, 0 rows affected (0.56 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('06/22/2019 01:10:20 PM');
Query OK, 1 row affected (0.13 sec)

mysql> insert into DemoTable values('06/22/2019 12:00:27 PM');
Query OK, 1 row affected (0.26 sec)

mysql> insert into DemoTable values('06/22/2019 06:56:20 AM');
Query OK, 1 row affected (0.23 sec)

mysql> insert into DemoTable values('06/22/2019 07:10:11 AM');
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------------------------+
| timestamp              |
+------------------------+
| 06/22/2019 01:10:20 PM |
| 06/22/2019 12:00:27 PM |
| 06/22/2019 06:56:20 AM |
| 06/22/2019 07:10:11 AM |
+------------------------+
4 rows in set (0.00 sec)
Following is the query to order by timestamp in MySQL −
mysql> select *from DemoTable ORDER BY STR_TO_DATE(`timestamp`,'%m/%d/%Y%h:%i:%s %p');
This will produce the following output −
+------------------------+
| timestamp              |
+------------------------+
| 06/22/2019 06:56:20 AM |
| 06/22/2019 07:10:11 AM |
| 06/22/2019 12:00:27 PM |
| 06/22/2019 01:10:20 PM |
+------------------------+
4 rows in set (0.00 sec)
What is the meaning of <> in MySQL query?

The symbol <> in MySQL is same as not equal to operator (!=). Both gives the result in boolean or tinyint(1). If the condition becomes true, then the result will be 1 otherwise 0.
Case 1 − Using != operator.
The query is as follows −
mysql> select 3!=5;
The following is the output.
+------+
| 3!=5 |
+------+
| 1    |
+------+
1 row in set (0.00 sec)
Case 2 − Using <> operator.
The query is as follows −
mysql> select 3 <> 5;
The following is the output.
+--------+
| 3 <> 5 |
+--------+
| 1      |
+--------+
1 row in set (0.00 sec)
The <> operator can be used to return a set of rows from the table. The <> is a standard ANSI SQL.
Let us first create a table. The query to create a table is as follows −
mysql> create table NotEqualOperator
-> (
-> StudentId int,
-> StudentName varchar(100),
-> StudentSection varchar(10)
-> );
Query OK, 0 rows affected (0.78 sec)
Insert some records in the table using insert command. The query is as follows.
mysql> insert into NotEqualOperator values(1,'John','A');
Query OK, 1 row affected (0.19 sec)

mysql> insert into NotEqualOperator values(2,'Carol','B');
Query OK, 1 row affected (0.19 sec)

mysql> insert into NotEqualOperator values(3,'Sam','A');
Query OK, 1 row affected (0.15 sec)

mysql> insert into NotEqualOperator values(4,'Mike','B');
Query OK, 1 row affected (0.23 sec)

mysql> insert into NotEqualOperator values(5,'Bob','B');
Query OK, 1 row affected (0.19 sec)

mysql> insert into NotEqualOperator values(6,'David','B');
Query OK, 1 row affected (0.14 sec)

mysql> insert into NotEqualOperator values(7,'Ramit','A');
Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement. The query is as follows.
mysql> select *from NotEqualOperator;
The following is the output.
+-----------+-------------+----------------+
| StudentId | StudentName | StudentSection |
+-----------+-------------+----------------+
| 1         | John        | A              |
| 2         | Carol       | B              |
| 3         | Sam         | A              |
| 4         | Mike        | B              |
| 5         | Bob         | B              |
| 6         | David       | B              |  
| 7         | Ramit       | A              |
+-----------+-------------+----------------+
7 rows in set (0.00 sec)
As discussed above, the <> operator can be used to return a set of rows. Now filter the above table to get those students only that does not belong to section A.
The query is as follows.
mysql> select *from NotEqualOperator where StudentSection <>'A';
The following is the output.
+-----------+-------------+----------------+
| StudentId | StudentName | StudentSection |
+-----------+-------------+----------------+
| 2         | Carol       | B              |
| 4         | Mike        | B              |
| 5         | Bob         | B              |
| 6         | David       | B              |
+-----------+-------------+----------------+
4 rows in set (0.00 sec)
How to create boxplot of vectors having different lengths in R?

If we have multiple vectors of different lengths then the boxplot for such vectors can be created by creating a single data frame using those vectors with a categorical column showing the name of the vectors and a numerical column having the corresponding values. Then boxplot function will be used as shown in the below example.
Consider the below vector x and y and create the data frame using them −
Live Demo
> x<-rpois(20,2)
> y<-rpois(15,2)
> df<-data.frame(X=c(x,y),Grp=rep(c("x","y"),times=c(20,15)))
> df
   X Grp
1  4   x
2  2   x
3  1   x
4  2   x
5  0   x
6  2   x
7  3   x
8  1   x
9  0   x
10 1   x
11 3   x
12 4   x
13 2   x
14 3   x
15 4   x
16 1   x
17 1   x
18 1   x
19 1   x
20 1   x
21 1   y
22 0   y
23 1   y
24 4   y
25 1   y
26 1   y
27 2   y
28 3   y
29 1   y
30 5   y
31 2   y
32 0   y
33 1   y
34 4   y
35 1   y
Creating the boxplot for groups in df −
> boxplot(X~Grp,data=df)
Calculate Factorial of a value in R Programming - factorial() Function - GeeksforGeeks

01 Jun, 2020
R Language offers a factorial() function that can compute the factorial of a number without writing the whole code for computing factorial.
Syntax: factorial(x)
Parameters:x: The number whose factorial has to be computed.
Returns: The factorial of desired number.
Example 1:
# R program to calculate factorial value     # Using factorial() method answer1 <- factorial(4) answer2 <- factorial(-3)  answer3 <- factorial(0)   print(answer1) print(answer2) print(answer3) 
Output:
24
NaN
1

Example 2:
# R program to calculate factorial value     # Using factorial() method answer1 <- factorial(c(0, 1, 2, 3, 4))   print(answer1) 
Output:
1  1  2  6 24

R Math-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Replace specific values in column in R DataFrame ?
Loops in R (for, while, repeat)
Filter data by multiple conditions in R using Dplyr
Change Color of Bars in Barchart using ggplot2 in R
How to change Row Names of DataFrame in R ?
Printing Output of an R Program
How to Change Axis Scales in R Plots?
Remove rows with NA in one column of R DataFrame
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
IMPORTING, EXPORTING and CHANGING Keywords in ABAP

IMPORTING transfers a value from the caller to the called method by passing an actual parameter
EXPORTING is just opposite to what IMPORTING does. IT passes value from the method to Caller.
CHANGING is transferring the value from caller to method by a variable which is processed or changed and the changed value is passed back to the Caller. Thus it combines both IMPORTING and EXPORTING function.
There are a couple of ways in which CHANGING can be used:
CHANGING myvar or CHANGING VALUE(myvar)
By using, CHANGING myvar , the value of a variable is changed and passed back to the caller or main program.
Using CHANGING VALUE(myvar) is a kind of exception handling. In case there is an exception or error in Subroutine, the value of a variable will be returned unchanged although it is possible that it has been changed in the subroutine.
How to clear a MongoDB database?

To clear, use dropDatabase. Following is the syntax −
use yourDatabaseName;
db.dropDatabase();
To clear a MongoDB database, first show all the databases −
> show dbs
This will produce the following output −
MyDB    0.000GB
admin    0.000GB
config    0.000GB
local    0.000GB
onlinecustomertracker 0.000GB
test    0.006GB
Now, let us delete the database onlinecustomertracker −
> use onlinecustomertracker
switched to db onlinecustomertracker
> db.dropDatabase();
{ "dropped" : "onlinecustomertracker", "ok" : 1 }
Following is the query to show all databases after deleting a database above −
> show dbs
This will produce the following output −
MyDB    0.000GB
admin    0.000GB
config    0.000GB
local    0.000GB
test    0.006GB
Python Input Methods for Competitive Programming?

In this we are going to see different ways of I/O methods for competitive programming in Python. In competitive programming it is important to read the input as fast as possible so as take advantage over others.
Suppose you’re in a codeforces or similar online jude (like SPOJ) and you have to read numbers a, b, c, d and print their product. There are multiple ways to do, let’s explore them – one by one
One way to doing it is either through list comprehension and map function.
Method 1: Using a list comprehension
a, b, c, d = [int(x) for x in input().split()]
print(a*b*c*d)
Method 2: Using the map function
a, b, c, d = map(int, input().split())
print(a*b*c*d)
Another way of doing above problem is using stdin and stdout which is much faster.
Method 1a: List comprehension with stdin and stdout
from sys import stdin, stdout
a, b, c, d = [int(x) for x in stdin.readline().rstrip().split()]
stdout.write(str(a*b*c*d) + "\n")
Let’s look at another problem from the competitive programming where we can test our input and output methods on the problems. The problem is called INTEST-Enormous Input Test on SPOJ.
Input
The input begins with two positive integers n k (n, k<=107). The next n lines of input contain one positive integer ti, not greater than 109, each.
Output
Write a single integer to output, denoting how many integers ti are divisible by k.
Where
INPUT: The input begins with two positive integers n and k (where- n, k <=10). The next lines of input contain one positive integer t not greater than 10*9 each.
INPUT: The input begins with two positive integers n and k (where- n, k <=10). The next lines of input contain one positive integer t not greater than 10*9 each.
OUTPUT: A single integer denoting how many integers t are divisible by k.
OUTPUT: A single integer denoting how many integers t are divisible by k.
For example
Input
7 3
1
51
966369
7
9
999996
11
Output
4
Method 1
One way to solve above problem is below though not the efficient one
def main():
   n, k = [int(c) for c in input().split()]
   cnt = 0
   for _ in range(n):
      t = int(input())
      if t % k == 0:
         cnt += 1
   print(cnt)

if __name__ == "__main__":
   main()
Method 2
Another more efficient way of solving above problem is using stdin and stdout. Below program runs much faster compared to the previous one.
from sys import stdin, stdout

def main():
   n, k = [int(c) for c in input().split()]
   cnt = 0
   for _ in range(n):
      t = int(stdin.readline())
      if t % k == 0:
         cnt += 1
   stdout.write(str(cnt))

if __name__ == "__main__":
   main()


Method 3
Another way to solve above problem which much faster than the previous two mentioned above is by using stdin and stdout (very similar to the way we used in method 2) however, read the whole input at once and load it into a list.
def main():
   for sys import stdin, stdout
   n, k = stdin.readline().split()
   n = int(n)
   k = int(k)

   cnt = 0
   lines = stdin.readlines()
   for line in lines:
      if int(line) % k == 0:
         cnt += 1
   stdout.write(str(cnt))

if __name__ == "__main__":
   main()
Python Program to Find the Gravitational Force Acting Between Two Objects

When it is required to find the gravitational force that acts between the two objects, a method named ‘find_gravity’ is used, and three parameters are passed to it.
Below is the demonstration of the same −
 Live Demo
def find_gravity(m_1, m_2, r):
   G_val = 6.673*(10**-11)
   F_val = (G_val*m_1*m_2)/(r**2)

   return round(F_val, 2)

m_1 = 6000000
m_2 = 1000000
r = 45
print("The gravitational force is: ")
print(find_gravity(m_1, m_2, r), "N")
The gravitational force is:
0.2 N
A method named ‘find_gravity’ is defined, that takes three parameters.
A method named ‘find_gravity’ is defined, that takes three parameters.
The gravitational force, and the gravitational constant are determined, and the force value is returned as output.
The gravitational force, and the gravitational constant are determined, and the force value is returned as output.
Outside the method, three integers are defined.
Outside the method, three integers are defined.
The method is called by passing these values as parameters.
The method is called by passing these values as parameters.
The output is displayed on the console.
The output is displayed on the console.
C# | How to change BufferWidth of the Console - GeeksforGeeks

28 Jan, 2019
Given the normal Console in C#, the task is to find the default value of Buffer Width and change it to something else.
Buffer Width refers to the current width of the buffer area of the console in columns.
Approach: This can be done using the Buffer Width property in the Console class of the System package in C#.
Program 1: Finding the default Buffer Width
// C# program to demonstrate the // Console.BufferWidth Propertyusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;  namespace GFG {  class Program {      // Main Method    static void Main(string[] args)    {          // Display current Buffer Width        Console.WriteLine("Default Buffer Width: {0}",                                Console.BufferWidth);    }}}
Output:
Program 2: Changing the Buffer Width to 100
// C# program to demonstrate the // Console.BufferWidth Propertyusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;  namespace GFG {  class Program {      static void Main(string[] args)    {          // Display current Buffer Width        Console.WriteLine("Default Buffer Width: {0}",                                 Console.BufferWidth);          // Set the Buffer Width to 100        Console.BufferWidth = 100;          // Display current Buffer Width        Console.WriteLine("Changed Buffer Width: {0}",                                 Console.BufferWidth);    }}}
Output:
Note: See how the horizontal scrolling bar on the bottom has changed in both the images.
CSharp-Console-Class
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 50 C# Interview Questions & Answers
Extension Method in C#
HashSet in C# with Examples
Partial Classes in C#
C# | Inheritance
Convert String to Character Array in C#
Linked List Implementation in C#
C# | How to insert an element in an Array?
C# | List Class
Difference between Hashtable and Dictionary in C#
Finding number of occurrences of a specific string in MySQL?

Use LENGTH() for this. Let us first create a table −
mysql> create table DemoTable
-> (
-> Value text
-> );
Query OK, 0 rows affected (0.74 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('10,20,10,30,10,40,50,40');
Query OK, 1 row affected (0.24 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------------------------+
| Value                   |
+-------------------------+
| 10,20,10,30,10,40,50,40 |
+-------------------------+
1 row in set (0.00 sec)
Following is the query to find number of occurrences of a specific string in MySQL. The occurrence of ‘10’ is what we are finding here −
mysql> select LENGTH(Value) + 2 -LENGTH(REPLACE(CONCAT(',', Value, ','), ',10,', 'len'))from DemoTable;
This will produce the following output −
+----------------------------------------------------------------------------+
| LENGTH(Value) + 2 -LENGTH(REPLACE(CONCAT(',', Value, ','), ',10,', 'len')) |
+----------------------------------------------------------------------------+
| 3                                                                          |
+----------------------------------------------------------------------------+
1 row in set (0.00 sec)
How to change the Drive letter using PowerShell?

To change the drive letter using PowerShell, we can use the Set−Partition command but before that, we need to know which drive letter to change. You can check the drive letter using Windows Explorer, Get−Partition, Gwmi win32_Logicaldisk, or Get−CimInstance Win32_Logicaldisk command.
Suppose we have an E: and we need to rename its drive letter to F, so we can use the below command.
Set−Partition −DriveLetter 'E' −NewDriveLetter 'F'
Make sure that the drive is not in use by Pagefile, open application, or open file from the drive otherwise the drive letter will fail to change.
To change the drive letter on the remote computer, you can connect to a remote session using the New−CIMSession command or using the Invoke−Command remote computer method.
With the CIM session command,
$sess = New−CimSession −ComputerName Labmachine2k12
Set−Partition −CimSession $sess −DriveLetter 'E' −NewDriveLetter 'F'
In the above example, we are using a remote computer name LabMachine2k12. You can change as per your remote system.
With the Invoke−Command method,
Invoke−Command −ComputerName Labmachine2k12 −ScriptBlock{Set−Partition −DriveLetter 'E' −NewDriveLetter 'F'}

You can also use the DiskID instead of DriveLetter.
How to bind events to Tkinter Canvas items?

Tkinter events can be bound with the widgets to perform a set of operations on the widgets. To be more specific, we can also bind an event handler to Canvas Items by using bind(<Button>, callback) method. Binding the event with the canvas item makes a canvas item dynamic which can be customized by event handlers.
#Import the required Libraries
from tkinter import *
import random

#Create an instance of Tkinter frame
win = Tk()

#Set the geometry of the window
win.geometry("700x350")

#Crate a canvas
canvas=Canvas(win,width=700,height=350,bg='white')
def draw_shapes(e):
   canvas.delete(ALL)

canvas.create_oval(random.randint(5,300),random.randint(1,300),25,25,fill='O rangeRed2')
canvas.pack()

#Bind the spacebar Key to a function
win.bind("<space>", draw_shapes)
win.mainloop()
Running the above code will display a window that contains a Canvas.
When we press the <Space> key, it will generate random shapes in the canvas window.
How to toggle a boolean using JavaScript?

Following is the code for toggling a Boolean using JavaScript −
 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 {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-weight: 500;
      font-size: 18px;
      color: blueviolet;
   }
</style>
</head>
<body>
<h1>Toggle a boolean using JavaScript</h1>
<div class="result"></div>
<button class="Btn">Toggle</button>
<h3>Click on the above button to toggle the above boolean value</h3>
<script>
   let BtnEle = document.querySelector(".Btn");
   let resEle = document.querySelector(".result");
   let boolVal = true;
   resEle.innerHTML = boolVal;
   BtnEle.addEventListener("click", () => {
      boolVal = !boolVal;
      resEle.innerHTML = boolVal;
   });
</script>
</body>
</html>
On clicking the Toggle button −
CSS Box Shadow

The CSS box-shadow property is used to apply 
one or more shadows to an element.
In its simplest use, you only specify a horizontal and a vertical shadow. The 
default color of the shadow is the current text-color.
Specify a horizontal and a vertical shadow:
The color parameter defines the color of the 
shadow.
Specify a color for the shadow:
The blur parameter defines the blur radius. The higher the number, the more 
blurred the shadow will be.
Add a blur effect to the shadow:
The spread parameter defines the spread radius. A positive value increases 
the size of the shadow, a negative value decreases the size of the shadow.
Set the spread radius of the shadow:
The inset parameter changes the shadow from 
an outer shadow (outset) to an inner shadow.
Add the inset parameter:
An element can also have multiple shadows:
You can also use the box-shadow property to create paper-like cards:
January 1, 2021
Hardanger, Norway
Set a "2px" horizontal, and "2px" vertical, text shadow for the <h1> element.
<style>
h1 {
  : 2px 2px;
}
</style>

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

Start the Exercise
The following table lists the CSS shadow properties:
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 | Font Border

30 Jul, 2021
Sometimes we need to create text and adding the outline to the text. There are mainly two methods to create a border to the fonts which are listed below: 
Using text-shadow property
Using text-stroke property
Method 1: Using text-shadow property: The text-shadow property is used to add font border or shadow to the text. Syntax:  
text-shadow: h-shadow v-shadow blur-radius color|none|initial|inherit;
Property Values:  
h-shadow: It sets horizontal shadow around the font.
v-shadow: It sets the vertical shadow around the font.
blur-radius: It sets the blur radius around the font.
color: It sets color around the font.
none: It does not set anything around the font.
initial: It sets the font border to its default value.
inherit: It inherits the property values from its parent values.
Return Value: It returns a font border/shadow around the text.Example 1: This example uses text-shadow property to create shadow to the text.  
html
<!DOCTYPE html><html>      <head>    <title>        CSS text-shadow property    </title>      <style>        h1 {            text-shadow: 0 0 3px #FF0000, 0 0 5px #0000FF;        }    </style></head>  <body>    <h1>GeeksforGeeks</h1></body>  </html>                    
Output:  
Example 2: This example uses text-shadow property to create bordered text.  
html
<!DOCTYPE html><html>      <head>    <title>        CSS text-shadow property    </title>          <!-- Style to use text-shadow property -->    <style>        .GFG {            color: white;            font-size: 50px;            text-shadow: -1px 1px 0 #000,                          1px 1px 0 #000,                         1px -1px 0 #000,                        -1px -1px 0 #000;        }    </style></head>  <body>    <p class="GFG">GeeksforGeeks</p>  </body>  </html>                    
Output:  
Method 2: Using text-stroke property: The text-stroke property is used to add stroke to the text. This property can be used to change the width and color of the text. This property is supported by using the -webkit- prefix.Example: This example uses text-stroke property to create bordered text.  
html
<!DOCTYPE html><html>      <head>    <title>        CSS text-stroke property    </title>          <!-- Style to use text-stroke property -->    <style>        .GFG {            color: white;            font-size: 50px;            -webkit-text-stroke-width: 1px;            -webkit-text-stroke-color: black;        }    </style></head>  <body>    <p class="GFG">GeeksforGeeks</p>  </body>  </html>                    
Output:  
Supported Browser:
Google Chrome 4.0
Internet Explorer 10.0
Firefox 3.5
Opera 9.6
Safari 4.0
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.
ajuanjojjj
ysachin2314
Picked
CSS
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sum of list (with string types) in Python

04 Dec, 2020
In Python, type of behavior will not change for data type. Below example is list containing integer type in string.so, we have to take all int type numbers from list even it is declared in string.
Examples:
Input : list1 = [12, 'geek', 2, '41', 'for', 10, '8', 6, 4, 'geeks', 7, '10']
Output : 100

Input : list1 = [100, 'geek', 200, '400', 'for', 101, '2018', 
                               64, 74, 'geeks', 27, '7810']
Output :10794

We use type() in Python and isdigit() in Python to achieve this.
# Python program to find sum of list with different# types.  def calsum(l):      # returning sum of list using List comprehension    return  sum([int(i) for i in l if type(i)== int or i.isdigit()])  # Declaring listlist1 = [12, 'geek', 2, '41', 'for', 10, '8', 6, 4, 'geeks', 7, '10']list2 = [100, 'geek', 200, '400', 'for', 101, '2018', 64, 74, 'geeks', 27, '7810']  # Result of sum of listprint (calsum(list1))print (calsum(list2))
python-list
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SAP ABAP - Do Loop

Unconditional loops repeatedly execute several statements without specifying any condition. The DO statement implements unconditional loops by executing a set of statement blocks several times unconditionally.
The general format for the DO statement is as follows −
DO [n TIMES]. 
 
<statement block>.
  
ENDDO.

‘Times’ imposes a restriction on the number of loop passes, which is represented by ‘n’. The value of ‘n’ should not be negative or zero. If it is zero or negative, the statements in the loop are not executed.
Report YH_SEP_15.
  
Do 15 TIMES. 
 
Write: / 'Hello'.
  
ENDDO.
The above code produces the following output −
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello 
Hello

In this example, the system understands that the loop is to be processed 15 times.
Java | Abstract Class and Interface | Question 2

22 Apr, 2022
Which of the following is true about interfaces in java.
1) An interface can contain following type of members.
....public, static, final fields (i.e., constants) 
....default and static methods with bodies

2) An instance of interface can be created.

3) A class can implement multiple interfaces.

4) Many classes can implement the same interface.
(A)
1, 3 and 4
(B)
1, 2 and 4
(C)
2, 3 and 4
(D)
1, 2, 3 and 4
Answer: (A)
Explanation: The instance of an interface can’t be created because it acts as an abstract class.
Quiz of this Question
anand8214370
Abstract Class and Interface
Java-Abstract Class and Interface
Java Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java | Constructors | Question 3
Java | Exception Handling | Question 2
Java | Functions | Question 1
Java | Exception Handling | Question 3
Java | Exception Handling | Question 4
Java | Exception Handling | Question 8
Java | Exception Handling | Question 7
Java | Exception Handling | Question 6
Java | Class and Object | Question 1
Java | Exception Handling | Question 8
Dictionary Methods in Python Program

A python dictionary is a collection data type which is wrapped in braces, {}, with a series of key value pairs inside the braces. Each key is connected to a value. We use a key to access the value associated with that key. A key can be a number, a string, a list, or even another dictionary.
There are many in-built methods available in the python Standard Library which is useful in dictionary operations. Below we will see the examples of most frequently used dictionary methods.
The method keys() returns a list of all the available keys in the dictionary.
 Live Demo
dict={'Name':'Harry','Rollno':30,'Dept':'cse','Marks':97}
print(dict.keys())
Running the above code gives us the following result
dict_keys(['Name', 'Rollno', 'Dept', 'Marks'])
This method returns a list of dictionary's (key, value) as tuple.
 Live Demo
dict={'Name':'Harry','Rollno':30,'Dept':'cse','Marks':97}
print(dict.items())
Running the above code gives us the following result
dict_items([('Name', 'Harry'), ('Rollno', 30), ('Dept', 'cse'), ('Marks', 97)])
This method returns list of dictionary dictionary's values from the key value pairs.
 Live Demo
dict={'Name':'Harry','Rollno':30,'Dept':'cse','Marks':97}
print(dict.values())
Running the above code gives us the following result:
dict_values(['Harry', 30, 'cse', 97])
The method pop(key) Removes and returns the value of specified key.
 Live Demo
dict={'Name':'Harry','Rollno':30,'Dept':'cse','Marks':97}
dict.pop('Marks')
print(dict)
Running the above code gives us the following result:
{'Name': 'Harry', 'Rollno': 30, 'Dept': 'cse'}
This method Returns a shallow copy of dictionary.
 Live Demo
dict={'Name':'Harry','Rollno':30,'Dept':'cse','Marks':97}
dict_new=dict.copy()
print(dict_new)
Running the above code gives us the following result:
{'Name': 'Harry', 'Rollno': 30, 'Dept': 'cse', 'Marks': 97}
The method clear() Removes all elements of dictionary.
 Live Demo
dict={'Name':'Harry','Rollno':30,'Dept':'cse','Marks':97}
dict.clear()
print(dict)
Running the above code gives us the following result:
{}
This method returns value of given key or None as default if key is not in the dictionary.
 Live Demo
dict={'Name':'Harry','Rollno':30,'Dept':'cse','Marks':97}
print('\nName: ', dict.get('Name'))
print('\nAge: ', dict.get('Age'))
Running the above code gives us the following result:
Name: Harry
Age: None
The update() inserts new item to the dictionary.
 Live Demo
dict={'Name':'Harry','Rollno':30,'Dept':'cse','Marks':97}
dict.update({'Age':22})
print(dict)
Running the above code gives us the following result
{'Name': 'Harry', 'Rollno': 30, 'Dept': 'cse', 'Marks': 97, 'Age': 22}
Complex Numbers in C#

To work WITH and display complex numbers in C#, you need to check for real and imaginary values.
A complex number like 7+5i is formed up of two parts, a real part 7, and an imaginary part 5. Here, the imaginary part is the multiple of i.
To display complete numbers, use the −
public struct Complex
To add both the complex numbers, you need to add the real and imaginary part −
public static Complex operator +(Complex one, Complex two) {
   return new Complex(one.real + two.real, one.imaginary + two.imaginary);
}
You can try to run the following code to work with complex numbers in C#.
 Live Demo
using System;
public struct Complex {
   public int real;
   public int imaginary;
   public Complex(int real, int imaginary) {
      this.real = real;
      this.imaginary = imaginary;
   }
   public static Complex operator +(Complex one, Complex two) {
      return new Complex(one.real + two.real, one.imaginary + two.imaginary);
   }
   public override string ToString() {
      return (String.Format("{0} + {1}i", real, imaginary));
   }
}
class Demo {
   static void Main() {
      Complex val1 = new Complex(7, 1);
      Complex val2 = new Complex(2, 6);
      // Add both of them
      Complex res = val1 + val2;
      Console.WriteLine("First: {0}", val1);
      Console.WriteLine("Second: {0}", val2);
      // display the result
      Console.WriteLine("Result (Sum): {0}", res);
      Console.ReadLine();
   }
}
First: 7 + 1i
Second: 2 + 6i
Result (Sum): 9 + 7i
Can we define an abstract class without abstract method in java?



A method which does not have body is known as abstract method. It contains only method signature with a semi colon and, an abstract keyword before it.
public abstract myMethod();
To use an abstract method, you need to inherit it by extending its class and provide implementation to it.
A class which contains 0 or more abstract methods is known as abstract class. If it contains at least one abstract method, it must be declared abstract.
And yes, you can declare abstract class without defining an abstract method in it. Once you declare a class abstract it indicates that the class is incomplete and, you cannot instantiate it.
Hence, if you want to prevent instantiation of a class directly you can declare it abstract.
If you want to use the concrete method in an abstract class you need to inherit the class, provide implementation to the abstract methods (if any) and then, you using the subclass object you can invoke the required methods.
In the following Java example, the abstract class MyClass contains a concrete method with name display.
From another class (AbstractClassExample) we are inheriting the class MyClass and invoking the its concrete method display using the subclass object.
 Live Demo
abstract class MyClass {
   public void display() {
      System.out.println("This is a method of abstract class");
   }
}
public class AbstractClassExample extends MyClass{
   public static void main(String args[]) {
      new AbstractClassExample().display();
   }
}
This is a method of abstract class