code-rag-bench/online-tutorials huggingface dataset:
Get similar words suggestion using Enchant in Python - GeeksforGeeks

14 Apr, 2018
For the given user input, get similar words through Enchant module.
Enchant is a module in python which is used to check the spelling of a word, gives suggestions to correct words. Also, gives antonym and synonym of words. It checks whether a word exists in dictionary or not. Other dictionaries can also be added, as, (“en_UK”), (“en_CA”), (“en_GB”) etc.
To install enchant :
pip install pyenchant
Examples :
Input : Helo
Output : Hello, Help, Hero, Helot, Hole

Input : Trth
Output : Truth, Trash, Troth, Trench

 Below is the implementation :
# Python program to print the similar# words using Enchant module  # Importing the Enchant moduleimport enchant  # Using 'en_US' dictionaryd = enchant.Dict("en_US")  # Taking input from userword = input("Enter word: ")  d.check(word)  # Will suggest similar words# form given dictionaryprint(d.suggest(word))
Output :
Enter word: aple

['pale', 'ale', 'ape', 'maple', 'ample', 'apple', 'plea', 'able', 'apse']

python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
How to Install PIP on Windows ?
Read a file line by line in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Create a Pandas DataFrame from Lists
Python String | replace()
Reading and Writing to text files in Python
*args and **kwargs in Python
How to drop one or multiple columns in Pandas Dataframe
SQL Tryit Editor v1.6

Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, Opera, and Edge(79).
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
How to overload Python comparison operators?

Python has magic methods to define overloaded behaviour of operators. The comparison operators (<, <=, >, >=, == and !=) can be overloaded by providing definition to __lt__, __le__, __gt__, __ge__, __eq__ and __ne__ magic methods. 
Following program overloads == and >= operators to compare objects of distance class.
class distance:
      def __init__(self, x=5,y=5):
            self.ft=x
            self.inch=y

      def __eq__(self, other):
             if self.ft==other.ft and self.inch==other.inch:
                  return "both objects are equal"
             else:
                  return "both objects are not equal"

       def __ge__(self, other):
                 in1=self.ft*12+self.inch
                 in2=other.ft*12+other.inch
                 if in1>=in2:
                    return "first object greater than or equal to other"
                  else:
                    return "first object smaller than other"

d1=distance(5,5)
d2=distance()
print (d1==d2)
d3=distance()
d4=distance(6,10)
print (d1==d2)
d5=distance(3,11)
d6=distance()
print(d5>=d6)
Result of above program shows overloaded use of == and >= comparison operators
both objects are equal
both objects are equal
first object smaller than other
C# Program to search for a string in an array of strings

Use Linq Contains() method to search for as specific string in an array of strings.
string[] arr = { "Bag", "Pen", "Pencil"};
Now, add the string in a string variable i.e. the string you want to search.
string str = "Pen";
Use the Contains() method to search the above string.
arr.AsQueryable().Contains(str);
Let us see the entire example.
 Live Demo
using System;
using System.Linq;
using System.Collections.Generic;
class Demo {
   static void Main() {
      string[] arr = { "Bag", "Pen", "Pencil"};
      string str = "Pen";
      bool res = arr.AsQueryable().Contains(str);
      Console.WriteLine("String Pen is in the array? "+res);
   }
}
String Pen is in the array? True
Set the Background Image Position with CSS

To set the background image position, use the background-position property. You can try to run the following code to learn how to work with the background-position property:
It sets the background image position 80 pixels away from the left side:
<html>
   <head>
      <style>
         body {
            background-image: url("/css/images/css.jpg");
            background-position:80px;
         }
      </style>
   </head>
   <body>
      <p>Tutorials point</>
   </body>
</html>
How to centre align action bar title in android?

This example demonstrates how do I centre align action bar title in android.
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"?>
<RelativeLayout
   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:padding="4dp"
   tools:context=".MainActivity">
   <TextView
      android:padding="4dp"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="My Action Bar"
      android:gravity="center"
      android:textSize="16sp"
      android:textStyle="bold"/>
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.java
import android.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
      getSupportActionBar().setCustomView(R.layout.activity_main);
   }
}
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="app.com.sample">
   <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 Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
Python program to find Union of two or more Lists?

Union operation means, we have to take all the elements from List1 and List 2 and all the elements store in another third list.
List1::[1,2,3]
List2::[4,5,6]
List3::[1,2,3,4,5,6]

Step 1: Input two lists.
Step 2: for union operation we just use + operator.

# UNION OPERATION
A=list()
B=list()
n=int(input("Enter the size of the List ::"))
print("Enter the Element of first list::")
for i in range(int(n)):
   k=int(input(""))
   A.append(k)
print("Enter the Element of second list::")
for i in range(int(n)):
   k=int(input(""))
   B.append(k)
   C = A + B
print("THE FINAL LIST IS ::>",C)
Enter the size of the List ::4
Enter the Element of first list::
23
11
22
33
Enter the Element of second list::
33
22
67
45
THE FINAL LIST IS ::> [23, 11, 22, 33, 33, 22, 67, 45]
What is the need of wrapper classes in Java?

In java.lang package you can find a set of classes which wraps a primitive variable with in their object these are known as wrapper classes. Following is the list of primitive datatypes and their respective classes −
 Live Demo
public class Sample {
   public static void main (String args[]){
      Integer obj = new Integer("2526");
      int i = obj.intValue();
      System.out.println(i);
   }
}
2526
Java provides primitive datatypes (char, byte, short, int, long, float, double, boolean) and, reference types to store values.
Whenever we pass primitive datatypes to a method the value of those will be passed instead of the reference therefore you cannot modify the arguments we pass to the methods. In this scenario you can use objects of such variables.
Classes in certain packages like util handles only objects.
Collection types such as ArrayList, Vectors etc. stores only objects (not primitive datatypes).
Your data need to be an objects for synchronization, serialization and, multithreading.
Therefore, at times we need to have primitive datatypes in the form of objects. At such scenarios you can use wrapper classes.
Docker Storage. In this section, we will discuss how... | by Sumeet Gyanchandani | Towards Data Science

In this section, we will discuss how docker stores data on the local file system, understand which layers are writable and would deepen our knowledge of persistent storage for containers.
IntroductionDocker FileBasic Docker CommandsPort and Volume MappingDocker NetworkingDocker Storage (You are here!)Docker ComposeDeleting Docker Entities
Introduction
Docker File
Basic Docker Commands
Port and Volume Mapping
Docker Networking
Docker Storage (You are here!)
Docker Compose
Deleting Docker Entities
On a linux system, docker stores data pertaining to images, containers, volumes, etc under /var/lib/docker.
When we run the docker build command, docker builds one layer for each instruction in the dockerfile. These image layers are read-only layers. When we run the docker run command, docker builds container layer(s), which are read-write layers.
You can create new files on the container, for instance, temp.txt in the image below. You can also modify a file that belongs to the image layers on the container, for instance, app.py in the image below. When you do this, a local copy of that file is created on the container layer and the changes only live on the container — this is called the Copy-on-Write mechanism. This is important as several containers and child images use the same image layers. The life of the files on the container is as long as the container is alive. When the container is destroyed, the files/modifications on it are also destroyed. To persist the data, we can use volume mapping techniques that we saw in the previous section.
You can create a docker volume by using the docker volume create command. This command will create a volume in the /var/lib/docker/volumes directory.
docker volume create data_volume
Now when you run the docker run command, you can specify which volume to use using the -v flag. This is called Volume Mounting.
docker run -v data_volume:/var/lib/postgres postgres
If the volume does not exist, docker creates one for you. Now, even if the container is destroyed the data will persist in the volume.
If you want to have your data on a specific location on the docker host or already have existing data on the disk, you can mount this location on the container as well. This is called Bind Mounting.
docker run -v /data/postgres:/var/lib/postgres postgres
In the next section, we will learn about Docker Compose, its file, and its commands.
Reference:
[1] Mumshad Mannambeth, Docker for the Absolute Beginners (2020), KodeKloud.com
Difference between text() and html() method in jQuery - GeeksforGeeks

21 Dec, 2020
Text() Method: This method returns the text content of the selected elements. It overwrites the content of all the matches element while setting the content.
Syntax:
To return text content:$(selector).text()
$(selector).text()
To set text content:$(selector).text(content)
$(selector).text(content)
To set the text content using a function:$(selector).text(function(index, currentcontent))
$(selector).text(function(index, currentcontent))
html() Method: This method is used to set or return the content (innerHTML) of the selected elements. It returns the content of the first matches element or sets the content of all matches elements.
Syntax:
Return content:$(selector).html()
Return content:
$(selector).html()
Set content:$(selector).html(content)
Set content:
$(selector).html(content)
Set content using a function:$(selector).html(function(index, currentcontent))
Set content using a function:
$(selector).html(function(index, currentcontent))
Example:
<!DOCTYPE html><html>  <head>    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">    </script>      <script>        $(document).ready(function () {            $("#button1").click(function () {                alert("Using text()- " + $("#demo").text());            });            $("#button2").click(function () {                prompt("Using html()- " + $("#demo").html());            });        });    </script></head>  <body>    <p id="demo">By clicking on the below buttons,        <b>difference</b> between        <i>text</i> and <i>html</i> in        <b>jQuery</b> is shown.    </p>      <button id="button1">Text</button>    <button id="button2">HTML</button></body>  </html>
Output:
Before clicking on buttons:
After clicking on Text Button:
After clicking on html Button:
Differences between text() and html() methods:
Supported Browsers:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
jQuery-Misc
Difference Between
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference between Process and Thread
Stack vs Heap Memory Allocation
Difference Between Method Overloading and Method Overriding in Java
Differences between JDK, JRE and JVM
JQuery | Set the value of an input text field
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to change the background color after clicking the button in JavaScript ?
How to add options to a select element using jQuery?
How to create a new table from merging two tables with MySQL union?

The following is the syntax to merge two tables using MySQL union
create table yourTableName
(
   select *from yourTableName1
)
UNION
(
   select *from yourTableName2
);
To understand the above syntax, let us create a table. The query to create first table is as follows
mysql> create table Old_TableDemo
   -> (
   -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> UserName varchar(20)
   -> );
Query OK, 0 rows affected (0.63 sec)
The query to create second table is as follows
mysql> create table Old_TableDemo2
   -> (
   -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   -> UserName varchar(20)
   -> );
Query OK, 0 rows affected (0.60 sec)
Insert some records in the first table using insert command. The query is as follows −
mysql> insert into Old_TableDemo(UserName) values('John');
Query OK, 1 row affected (0.22 sec)
mysql> insert into Old_TableDemo(UserName) values('Carol');
Query OK, 1 row affected (0.15 sec)
Display all records from the first table using select statement. The query is as follows −
mysql> select *from Old_TableDemo;
The following is the output
+--------+----------+
| UserId | UserName |
+--------+----------+
|      1 | John     |
|      2 | Carol    |
+--------+----------+
2 rows in set (0.00 sec)
Now you can insert some records in the second table using insert command. The query is as follows −
mysql> insert into Old_TableDemo2(UserName) values('Larry');
Query OK, 1 row affected (0.22 sec)
mysql> insert into Old_TableDemo2(UserName) values('Sam');
Query OK, 1 row affected (0.10 sec)
Display all records from the second table using select statement. The query is as follows −
mysql> select *from Old_TableDemo2;
The following is the output
+--------+----------+
| UserId | UserName |
+--------+----------+
|      1 | Larry    |
|      2 | Sam      |
+--------+----------+
2 rows in set (0.00 sec)
Here is the query to create a new table from merging two tables with union
mysql> create table UserTableDemo
   -> (
   -> select *from Old_TableDemo
   -> )
   -> UNION
   -> (
   -> select *from Old_TableDemo2
   -> );
Query OK, 4 rows affected (1.18 sec)
Records: 4 Duplicates: 0 Warnings: 0
Let us check the table records of new table. The query is as follows −
mysql> select *from UserTableDemo;
The following is the output
+--------+----------+
| UserId | UserName |
+--------+----------+
|      1 | John     |
|      2 | Carol    |
|      1 | Larry    |
|      2 | Sam      |
+--------+----------+
4 rows in set (0.00 sec)
Dictionary Methods in Java

Dictionary is an abstract class that represents a key/value storage repository and operates much like Map. Given a key and value, you can store the value in a Dictionary object. Once the value is stored, you can retrieve it by using its key. Thus, like a map, a dictionary can be thought of as a list of key/value pairs.
Following are the methods defined by Dictionary are listed below −
Following is an example implementing put() and get() method of the Dictionary class −
import java.util.*;
public class Demo {
   public static void main(String[] args) {
      Dictionary dictionary = new Hashtable();
      dictionary.put("20", "John");
      dictionary.put("40", "Tom");
      dictionary.put("60", "Steve");
      dictionary.put("80", "Kevin");
      dictionary.put("100", "Ryan");
      dictionary.put("120", "Tim");
      dictionary.put("140", "Jacob");
      dictionary.put("160", "David");
      System.out.println("Value at key 20 = " + dictionary.get("20"));
      System.out.println("Value at key 40 = " + dictionary.get("40"));
      System.out.println("Value at key 30 = " + dictionary.get("30"));
      System.out.println("Value at key 90 = " + dictionary.get("90"));
   }
}
Value at key 20 = John
Value at key 40 = Tom
Value at key 30 = null
Value at key 90 = null
Let us see another example wherein we are displaying the Dictionary values as well using the elements () method −
import java.util.*;
public class Demo {
   public static void main(String[] args) {
      Dictionary dictionary = new Hashtable();
      dictionary.put("20", "John");
      dictionary.put("40", "Tom");
      dictionary.put("60", "Steve");
      dictionary.put("80", "Kevin");
      dictionary.put("100", "Ryan");
      dictionary.put("120", "Tim");
      dictionary.put("140", "Jacob");
      dictionary.put("160", "David");
      System.out.println("Dictionary Values...");
      for (Enumeration i = dictionary.elements(); i.hasMoreElements();) {
         System.out.println(i.nextElement());
      }
      System.out.println("Value at key 20 = " + dictionary.get("20"));
      System.out.println("Value at key 40 = " + dictionary.get("40"));
      System.out.println("Value at key 30 = " + dictionary.get("30"));
      System.out.println("Value at key 90 = " + dictionary.get("90"));
   }
}
Dictionary Values...
Tom
Jacob
Steve
Ryan
David
John
Kevin
Tim
Value at key 20 = John
Value at key 40 = Tom
Value at key 30 = null
Value at key 90 = null
How to get nth row in a Pandas DataFrame?

To get the nth row in a Pandas DataFrame, we can use the iloc() method. For example, df.iloc[4] will return the 5th row because row numbers start from 0.
Make two-dimensional, size-mutable, potentially heterogeneous tabular data, df.
Print input DataFrame, df.
Initialize a variable nth_row.
Use iloc() method to get nth row.
Print the returned DataFrame.
import pandas as pd

df = pd.DataFrame(
   dict(
      name=['John', 'Jacob', 'Tom', 'Tim', 'Ally'],
      marks=[89, 23, 100, 56, 90],
      subjects=["Math", "Physics", "Chemistry", "Biology", "English"]
   )
)

print "Input DataFrame is:\n", df
nth_row = 3
df = df.iloc[nth_row]
print "Row ", nth_row, "of the DataFrame is: \n", df
Input DataFrame is:
    name   marks   subjects
0   John    89         Math
1  Jacob    23      Physics
2    Tom   100    Chemistry
3    Tim    56      Biology
4   Ally    90      English

Row 3 of the DataFrame is:
name            Tim
marks            56
subjects    Biology
Name: 3, dtype: object
How to remove a directory in R? - GeeksforGeeks

14 Sep, 2021
In this article, we will discuss how to remove a directory using R programming language.
To remove a directory in R we use unlink(). This function deletes the named directory.
Syntax: unlink(directory-name, recursive = BOOLEAN)
Parameter:
directory-name: a character vector with the names of the directories to be deleted.
recursive: BOOLEAN TRUE/FALSE, if true directory is deleted recursively otherwise only empty directories are deleted.
Return: It returns normally 0 for success, 1 for failure. Not deleting a non-existent file is not a failure so in that case return 0.
Note: File naming conventions depend on the platform.
Directory in use:
Directory used
Example: Removing directory using R programming language
R
# list files or directories in working directory list.files(path=".", pattern=NULL, all.files=FALSE,    full.names=FALSE)  # delete the directory demo in working directoryunlink("Demo",recursive=TRUE)  # list files or directories in working directory # after deletionlist.files(path=".", pattern=NULL, all.files=FALSE,    full.names=FALSE)
Output:
Console Output
Final Directory after running the above code:
Final state of Directory
Picked
R directory-programs
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
How to filter R dataframe by multiple conditions?
Replace Specific Characters in String in R
Time Series Analysis in R
R - if statement
C++ Program to Implement Bubble Sort

Bubble Sort is comparison based sorting algorithm. In this algorithm adjacent elements are compared and swapped to make correct sequence. This algorithm is simpler than other algorithms, but it has some drawbacks also. This algorithm is not suitable for large number of data set. It takes much time to solve the sorting tasks.
Time Complexity: O(n) for best case, O(n2) for average and worst case
Time Complexity: O(n) for best case, O(n2) for average and worst case
Space Complexity: O(1)
Space Complexity: O(1)
Input − A list of unsorted data: 56 98 78 12 30 51
Output − Array after Sorting: 12 30 51 56 78 98
Input: An array of data, and the total number in the array
Output: The sorted Array
Begin
   for i := 0 to size-1 do
      flag := 0;
      for j:= 0 to size –i – 1 do
         if array[j] > array[j+1] then
            swap array[j] with array[j+1]
            flag := 1
      done
      if flag ≠ 1 then
         break the loop.
   done
End
#include<iostream>
using namespace std;
void swapping(int &a, int &b) {      //swap the content of a and b
   int temp;
   temp = a;
   a = b;
   b = temp;
}
void display(int *array, int size) {
   for(int i = 0; i<size; i++)
      cout << array[i] << " ";
   cout << endl;
}
void bubbleSort(int *array, int size) {
   for(int i = 0; i<size; i++) {
      int swaps = 0;         //flag to detect any swap is there or not
      for(int j = 0; j<size-i-1; j++) {
         if(array[j] > array[j+1]) {       //when the current item is bigger than next
            swapping(array[j], array[j+1]);
            swaps = 1;    //set swap flag
         }
      }
      if(!swaps)
         break;       // No swap in this pass, so array is sorted
   }
}
int main() {
   int n;
   cout << "Enter the number of elements: ";
   cin >> n;
   int arr[n];     //create an array with given number of elements
   cout << "Enter elements:" << endl;
   for(int i = 0; i<n; i++) {
      cin >> arr[i];
   }
   cout << "Array before Sorting: ";
   display(arr, n);
   bubbleSort(arr, n);
   cout << "Array after Sorting: ";
   display(arr, n);
}
Enter the number of elements: 6
Enter elements:
56 98 78 12 30 51
Array before Sorting: 56 98 78 12 30 51
Array after Sorting: 12 30 51 56 78 98
Java program to convert a string to lowercase and uppercase.

Live Demo
import java.lang.*;
public class StringDemo {
   public static void main(String[] args) {  
      // converts all upper case letters in to lower case letters
      String str1 = "SELF LEARNING CENTER";
      System.out.println("string value = " + str1.toLowerCase());

      str1 = "TUTORIALS POINT";    
      System.out.println("string value = " + str1.toLowerCase());

      // converts all lower case letters in to upper case letters
      String str2 = "This is TutorialsPoint";
      System.out.println("string value = " + str2.toUpperCase());

      str2 = "www.tutorialspoint.com";
      System.out.println("string value = " + str2.toUpperCase());      
   }  
} 
string value = self learning center
string value = tutorials point
string value = THIS IS TUTORIALSPOINT
string value = WWW.TUTORIALSPOINT.COM
Difference between continue and break statements in Java

As we know in programming execution of code is done line by line.Now in order to alter this flow C++ provides two statements break and coninue which mainly used to skip some specific code at specific line.
Following are the important differences between continue and break.
JavaTester.java
 Live Demo
public class JavaTester{
   public static void main(String args[]){
      // Illustrating break statement (execution stops when value of i becomes to 4.)
      System.out.println("Break Statement\n");
      for(int i=1;i<=5;i++){
         if(i==4) break;
         System.out.println(i);
      }
      // Illustrating continue statement (execution skipped when value of i becomes to 1.)
      System.out.println("Continue Statement\n");
      for(int i=1;i<=5;i++){
         if(i==1) continue;
         System.out.println(i);
      }
   }
}
Break Statement
1
2
3

Continue Statement
2
3
4
5
Count numbers upto N which are both perfect square and perfect cube in C++

We are given a number N. The goal is to count the numbers upto N that are perfect squares as well as perfect cubes. For example, 1, 64 are both perfect squares and perfect cubes.
We will use sqrt() to calculate square root and cbrt() to calculate cube root of a number.
Let’s understand with examples.
Input − N=100
Output − Count of numbers that are perfect squares and cubes − 2
Explanation − 1 and 64 are only numbers from 1 to 100 that are both perfect squares and cubes.
Input − N=5000
Output −Count of numbers that are perfect squares and cubes − 3
Explanation − 1, 64 and 4096 are only numbers from 1 to 5000 that are both perfect squares and cubes.
We take an integer N.
We take an integer N.
Function getCount(int n) takes N and returns the count of numbers upto N that are both perfect squares and perfect cubes.
Function getCount(int n) takes N and returns the count of numbers upto N that are both perfect squares and perfect cubes.
Take the initial count as 0.
Take the initial count as 0.
Starting from i=1 to i=N, if floor(sqrt(i))==ceil(sqrt(i)) then i is a perfect square.
Starting from i=1 to i=N, if floor(sqrt(i))==ceil(sqrt(i)) then i is a perfect square.
Now check if floor(cbrt(i))==ceil(cbrt(i)), if true i is also a perfect cube. Increment count.
Now check if floor(cbrt(i))==ceil(cbrt(i)), if true i is also a perfect cube. Increment count.
At the end of loop return count as result.
At the end of loop return count as result.
 Live Demo
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int getCount(int n){
   int count=0;
   for(int i=1;i<=n;i++){
      if(floor(sqrt(i))==ceil(sqrt(i))){
         if(floor(cbrt(i))==ceil(cbrt(i))){
            count++;
            //cout<<i<<" ";
         }
      }
   }
   return count;
}
int main(){
   int N=100;
   cout<<endl<<"Numbers upto N that are perfect squares and perfect cubes:"<<getCount(N);
   return 0;
}
If we run the above code it will generate the following output −
Numbers upto N that are perfect squares and perfect cubes:2
Bootstrap 4 .border-right-0 class

Use the border-right-0 class in Bootstrap to remove the right border.
To remove the right border −
<div class="mystyle border border-right-0">
  Rectangle is missing the right border.
</div>
Style the div as −
.mystyle {
  width: 350px;
  height: 170px;
  margin: 10px;
}
You can try to run the following code to implement the border-right- 0 class −
Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  <style>
  .mystyle {
    width: 350px;
    height: 170px;
    margin: 10px;
  }
  </style>
</head>
<body>
  <div class="container">
    <h2>Heading Two</h2>
    <div class="mystyle border border-right-0">Rectangle is missing the right border.</div>
  </div>
</body>
</html>
How can I define underlined text in an Android layout xml file?

This example demonstrate about How can I define underlined text in an Android layout xml file.
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.java
<? xml version= "1.0" encoding= "utf-8" ?>
<RelativeLayout 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"
   tools :context= ".MainActivity" >
   <TextView
      android :id= "@+id/textView"
      android :layout_width= "match_parent"
      android :layout_height= "wrap_content"
      android :layout_centerInParent= "true"
      android :gravity= "center"
      android :padding= "16dp"
      android :text= "Bottom of the screen"
      android :textAppearance= "@style/Base.TextAppearance.AppCompat.Large" />
</RelativeLayout>
Step 3 − Add the following code to src/MainActivity.java
package app.tutorialspoint.com.sample ;
import android.os.Bundle ;
import android.support.v7.app.AppCompatActivity ;
import android.text.SpannableString ;
import android.text.style.UnderlineSpan ;
import android.widget.TextView ;
public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate (Bundle savedInstanceState) {
      super .onCreate(savedInstanceState) ;
      setContentView(R.layout. activity_main ) ;
      TextView textView = findViewById(R.id. textView ) ;
      SpannableString content = new SpannableString( "Content" ) ;
      content.setSpan( new UnderlineSpan() , 0 , content.length() , 0 ) ;
      textView.setText(content) ;
   }
}
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= "app.tutorialspoint.com.sample" >
   <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 Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen –
Subarray Sum Equals K in C++

Suppose we have an array of integers and an integer k, we need to find the total number of continuous subarrays whose sum same as k. So if nums array is [1, 1, 1] and k is 2, then the output will be 2.
To solve this, we will follow these steps −
define one map called sums, temp := 0, sums[0] := 1 and ans := 0
for i in range 0 to size of the arraytemp := temp + n[i]if sums has k – temp, thenans := ans + sums[k - temp]increase the value of sums[-temp] by 1
temp := temp + n[i]
if sums has k – temp, thenans := ans + sums[k - temp]
ans := ans + sums[k - temp]
increase the value of sums[-temp] by 1
return ans
Let us see the following implementation to get a better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
   int subarraySum(vector<int>& n, int k) {
      unordered_map <int, int> sums;
      int temp = 0;
      sums[0] = 1;
      int ans =0;
      for(int i =0;i<n.size();i++){
         temp+= n[i];
         if(sums.find(k-temp)!=sums.end()){
            ans += sums[k-temp];
         }
         sums[-temp]++;
      }
      return ans;
   }
};
main(){
   Solution ob;
   vector<int> v = {1,1,1};
   cout << (ob.subarraySum(v, 2));
}
[1,1,1]
2
2
How to create a ListView using JavaFX?

A list view is a scrollable list of items from which you can select desired items. You can create a list view component by instantiating the javafx.scene.control.ListView class. You can create either a vertical or a horizontal ListView.
Following the JavaFX program demonstrates the creation of a ListView.
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
public class ListViewExample extends Application {
   public void start(Stage stage) {
      //Label for education
         Label label = new Label("Educational qualification:");
      Font font = Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 12);
      label.setFont(font);
      //list View for educational qualification
      ObservableList<String> names = FXCollections.observableArrayList("Engineering", "MCA", "MBA", "Graduation", "MTECH", "Mphil", "Phd");
      ListView<String> listView = new ListView<String>(names);
      listView.setMaxSize(200, 160);
      //Creating the layout
      VBox layout = new VBox(10);
      layout.setPadding(new Insets(5, 5, 5, 50));
      layout.getChildren().addAll(label, listView);
      layout.setStyle("-fx-background-color: BEIGE");
      //Setting the stage
      Scene scene = new Scene(layout, 595, 200);
      stage.setTitle("List View Example");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
How to Count Elements in C# Array?

30 Sep, 2021
To count the number of elements in the C# array, we can use the count() method from the IEnumerable. It is included in the System.Linq.Enumerable class. The count method can be used with any type of collection such as an array, ArrayList, List, Dictionary, etc.
Syntax:
Count<TSource>()
 This method returns the total number of elements present in an array.
Count<TSource>(Func<TSource, Boolean>) 
This method returns the total number of elements in an array that matches the specified condition using Func delegate.
Example 1: Using String values in the array.
In the below code block, we have implemented the count function to count the number of elements in a C# Array. Firstly, we have used the System.Linq, because the count function is located in this class, then we have created a count variable to count the number of elements in the array. After that, we have created an array of strings with 6 elements in it. Then we have used the Count function in the array and store the resultant count into the count variable that we have created earlier. Then using the console. Write line we are displaying the count of elements in the array.
C#
// C# program to illustrate the above conceptusing System;using System.Linq;  class GFG{  static public void Main(){          // Initializing count variable    var totalCount = 0;      // Creating an array of strings    string[] elements = { "Rem", "Hisoka", "Gon",                           "Monkey D Luffy", "Alvida",                           "Shank" };      // Invoking count function on the above elements    totalCount = elements.Count();      // Displaying the count    Console.WriteLine(totalCount);}}
6
Example 2: Using integer values in the array.
C#
// C# program to illustrate the above conceptusing System;using System.Linq;  class GFG{  static public void Main(){          // Creating a count variable    var total = 0;      // creating array of numbers    int[] nums = { 9, 6, 5, 2, 1, 5, 8, 4,                   6, 2, 3, 4, 8, 7, 5, 6 };      // Counting the number of elements    total = nums.Count();      // Displaying the count    Console.WriteLine(total);}}
16
Example 3: To count specific elements based on conditions within the array.
Here, in the below program, we are creating an array of colors, and then using the count method, we are finding the number of times the color “Blue” appears in the array. Then displaying the count.
C#
// C# program to illustrate the above conceptusing System;using System.Linq;  class GFG{  static public void Main(){          // Creating a count variable    var total = 0;      // Creating an array of colors    string[] colors = { "Red", "Blue", "Black",                        "White", "Blue", "Blue" };      // Counting the total number of time blue appears    // in the array    total = colors.Count(c => c == "Blue");      // Displaying the count    Console.WriteLine(total);}}
Output:
3
CSharp-Arrays
Picked
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PyQt5 – How to hide app from taskbar ? - GeeksforGeeks

26 Mar, 2020
While creating a PyQt5 app the window get opened and in task bar, automatically the app appears and when we close the app it get removed.
A taskbar is an element of a graphical user interface which has various purposes. It typically shows which programs are currently running. The specific design and layout of the taskbar varies between individual operating systems, but generally assumes the form of a strip located along one edge of the screen.
In this article we will see how to hide the app from the task bar, in order to do so we will use setWindowFlag() method and pass which belongs to the QWidget class.
Syntax : setWindowFlag(QtCore.Qt.Tool)
Argument : It takes Window type as argument.
Action performed : It hides the app from the task bar.
Code :
# importing the required libraries  from PyQt5.QtWidgets import * from PyQt5.QtGui import * from PyQt5 import QtCoreimport sys    class Window(QMainWindow):    def __init__(self):        super().__init__()          # this will hide the app from task bar        self.setWindowFlag(QtCore.Qt.Tool)          # set the title        self.setWindowTitle("NO task bar")          # setting  the geometry of window        self.setGeometry(60, 60, 800, 500)          # creating a label widget        # by default label will display at top left corner        self.label_1 = QLabel('no task bar', self)          # moving position        self.label_1.move(100, 100)          # setting up border and background color        self.label_1.setStyleSheet("background-color: lightgreen;                                    border: 3px solid green")          # show all the widgets        self.show()    # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()# start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Defaultdict in Python
Python OOPs Concepts
Python | os.path.join() method
Python | Pandas dataframe.groupby()
HTML | DOM innerText Property - GeeksforGeeks

25 Jul, 2019
The DOM innerText Property is used to set or returns the text content of a specified node and its descendants. This property is very similar to text content property but returns the content of all elements, except for <script> and <style> elements.
Syntax: It is used to set the innerText property.
node.innerText = text 
Return Value: It returns a string value which represent the text content of the element along with its descendants.Example-1:
<!DOCTYPE html><html>  <head>    <title>        HTML DOM innerText Property    </title></head>  <body>    <h1>GeeksforGeeks</h1>    <h2>HTML DOM textContent Property</h2>      <button id="geeks" onclick="MyGeeks()">        Submit    </button>      <p id="sudo"></p>    <script>        function MyGeeks() {            var text =                document.getElementById("geeks").innerText;            document.getElementById("sudo").innerHTML = text;        }    </script></body>  </html>         
Output :Before clicking on the Button:
After clicking on the Button:
Example-2:
<!DOCTYPE html><html>  <head>    <title>        HTML DOM innerText Property    </title></head>  <body>    <center>        <h1>GeeksforGeeks</h1>        <h2>HTML DOM innerText Property</h2>        <p id="geeks" style="font-size:20px;">Hello Geeks!</p>        <button onclick="MyGeeks()">            Submit        </button>        <!-- MyGeeks function replace the inner text-->        <script>            function MyGeeks() {                document.getElementById("geeks").innerText =                                  "Welcome to GeeksforGeeks!";            }        </script>    </center></body>  </html>      
Output :Before clicking on The Button:After clicking on the Button:
Supported Browsers: The browser supported by DOM innerText property are listed below:
Google Chrome 1.0
Internet Explorer 4.0
Firefox 1.0
Opera 3.5
Safari 1.0
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.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Python | sympy.cot() method - GeeksforGeeks

17 Jul, 2019
With the help of sympy.cot() method, we are able to find the value of cot theta using sympy.cot() function.
Syntax : sympy.cot()Return : Return value of cot theta.
Example #1 :In this example we can see that by using sympy.cot() method, we can find the value of cot theta.
# import sympyfrom sympy import *  # Use sympy.cot() methodgfg = simplify(cot(pi / 3))    print(gfg)
Output :
sqrt(3)/3
Example #2 :
# import sympyfrom sympy import *  # Use sympy.cot() methodgfg = simplify(cot(pi / 4))    print(gfg)
Output :
1
SymPy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Python | Get unique values from a list
Python for finance: an implementation of the Modern Portfolio Theory | by Riccardo Poli | Towards Data Science

The Modern Portfolio Theory
The Modern portfolio theory (MPT) is a financial theory that describes, in mathematical terms, concepts such as diversification and risk management. The MPT offers the investor a toolset for building a diversified portfolio, whose return is maximised for a given level of risk. The risk is commonly measured with the standard deviation.
The theory was introduced by the economist Harry Markowitz, that was awarded the Nobel Prize in Economics in 1990 for this research work. The mathematical formulation of the theory involves concepts such as variance and covariance. If you are interested in the details, please visit the dedicated Wikipedia page.
The Efficient Frontier
The concept of the Efficient Frontier can be formally defined as the set of portfolios that have the highest return at any given risk and it is closely coupled with the MPT. This frontier usually has a “C” shape, as in the figure below, and three points can be distinguished:
The portfolio with minimum risk.
The portfolio with maximum return.
The portfolio with maximum Sharpe ratio, which is typically the investors’ preferred choice, as it thought to be a good compromise between the level of risk and the expected return.
Python implementation of the MPT
The Python notebook presented below enables the user to easily explore the design space of investment opportunities, by simulating a customised number of portfolios, and creates an interactive dashboard that can be used to choose the desired trading strategy.
The full code can be found at the link below, on my GitHub page, together with other scripts of the series “python for finance”.
github.com
The implementation is made in Python 3 and the download of the data is made through the FINNHUB Application Programming Interface (API). The user will need to register (registration is free) to obtain a personal API key.
The script consists of 3 sections: input section, main body and plotting section. The user has to specify the following inputs:
The list of symbols of stocks or the exchange traded funds (ETFs) of interest (e.g. “TSLA” for Tesla, Inc.; “VOO” for the Vanguard 500 Index Fund ETF, etc.), including a short description of each stocks or ETFs.
The number of portfolios she/he wants to simulate.
The range of dates she/he wants to use to perform the back-testing.
The API key, which can be easily obtained for free here.
## DEFINE INPUTS  ticks = ["EMB", "AGG", "VGT", "TSLA", "AMZN"] line_name = ["Emerging countries debt", "US debt", "S&P 500 Vanguard ETF", "Tesla", "Amazon"] num_port = 1000 start_date = '01/06/2015' end_date = '27/06/2020' api_key = "YOUR API KEY"
You can find further comments on the code and additional details in the notebook on my GitHub page. There, you will also find other tools of the “Python for finance” series.
Enjoy, and happy trading!
Riccardo Poli https://www.linkedin.com/in/riccardopoli/
Disclaimer: investing in the stock market involves risk and can lead to monetary loss. The content of this article is not to be taken as financial advice.