code-rag-bench/online-tutorials huggingface dataset:
QBColor() and RGB() Function in MS Access

27 Sep, 2021
1. QBColor() Function : QBColor() Function in MS Access is used to get the RGB color code .It returns a Long number representing the RGB color code corresponding to the specified color number. 
Syntax :  
QBColor (color)
Parameter : This method accepts one parameter as mentioned above and described below :  
color : It is a whole number in the range 0–15.
Returns : It returns RGB color code. 
Example-1 : RGB color code of White whose color number is 7.  
SELECT  QBColor( 7);
Output :  
12632256 
Example-2 : RGB color code of Green whose color number is 2.  
SELECT  QBColor( 2);
Output :  
32768 
2. RGB () Function : RGB() Function in MS Access is used to get a Long number which represents an RGB color value. 
Syntax :  
RGB (red, green, blue)
Parameter : This method accepts three parameter as mentioned above and described below :  
red : It represents the red component of the color. It is an Integer Number in the range 0–255(inclusive).  
green : It represents green red component of the color. It is an Integer Number in the range 0–255(inclusive).  
blue : It represents the blue component of the color. It is an Integer Number in the range 0–255(inclusive).  
Returns : It returns RGB color value. 
Example-1 : RGB color value for White whose red value is 255, green value is 255 and blue value is 255.  
SELECT  RGB(255, 255, 255);
Output :  
16777215 
Example-2 : RGB color code of Green whose red value is 0, green value is 255 and blue value is 0.  
SELECT  RGB(0, 255, 0);
Output : 
65280 
sweetyty
DBMS-SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Sub queries in From Clause
Window functions in SQL
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
What is Temporary Table in SQL?
SQL using Python
RANK() Function in SQL Server
SQL Query to Convert VARCHAR to INT
SQL Query to Compare Two Dates
SQL | DROP, TRUNCATE
Python | Accessing nth element from tuples in list

23 Dec, 2018
While working with tuples, we store different data as different tuple elements. Sometimes, there is a need to print a specific information from the tuple. For instance, a piece of code would want just names to be printed of all the student data. Lets discuss certain ways how one can achieve solutions to this problem.
Method #1 : Using list comprehensionList comprehension is the simplest way in which this problem can be solved. We can just iterate over only the specific index value in all the index and store it in a list and print it after that.
# Python3 code to demonstrate # get nth tuple element from list# using list comprehension   # initializing list of tuplestest_list = [(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]  # printing original list print ("The original list is : " + str(test_list))  # using list comprehension to get namesres = [lis[1] for lis in test_list]      # printing resultprint ("List with only nth tuple element (i.e names) : " + str(res))
Output :
The original list is : [(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]
List with only nth tuple element (i.e names) : ['Rash', 'Varsha', 'Kil']

Method #2 : Using map() + itemgetter()map() coupled with itemgetter() can perform this task in more simpler way. map() maps all the element we access using itemgetter() and returns the result.
# Python3 code to demonstrate # get nth tuple element from list# using map() + itergetter()from operator import itemgetter  # initializing list of tuplestest_list = [(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]  # printing original list print ("The original list is : " + str(test_list))  # using map() + itergetter() to get namesres = list(map(itemgetter(1), test_list))      # printing resultprint ("List with only nth tuple element (i.e names) : " + str(res))
Output :
The original list is : [(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]
List with only nth tuple element (i.e names) : ['Rash', 'Varsha', 'Kil']

Method #3 : Using zip()The most conventional and pythonic way to perform this particular task is using this function. This collects all the nth tuple elements into a single container and returns the result. This only works for Python 2.
# Python code to demonstrate # get nth tuple element from list# using zip()  # initializing list of tuplestest_list = [(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]  # printing original list print ("The original list is : " + str(test_list))  # using zip() to get namesres = list(zip(*test_list)[1])      # printing resultprint ("List with only nth tuple element (i.e names) : " + str(res))
Output :
The original list is : [(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]
List with only nth tuple element (i.e names) : ['Rash', 'Varsha', 'Kil']

Python list-programs
python-list
python-tuple
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Math.Log10() Method

31 Jan, 2019
In C#, Math.Log10() is a Math class method. It is used to return the base 10 logarithm of a specified number.
Syntax:
public static double Log10(double val)
Parameter:
val: It is the specified number whose logarithm to be calculated and its type is System.Double.
Return Value: It returns the logarithm of val(base 10 log of val) and its type is System.Double.
Note: Parameter val is always specified as a base 10 number. The return value is depend on the argument passed. Below are some cases:
If the argument is positive then method will return the natural logarithm or log10(val).
If the argument is zero, then the result is NegativeInfinity.
If the argument is Negative(less than zero) or equal to NaN, then the result is NaN.
If the argument is PositiveInfinity, then the result is PositiveInfinity.
If the argument is NegativeInfinity, then the result is NaN.
Example:
// C# program to demonstrate working// of Math.Log10(Double) methodusing System;  class Geeks {      // Main Method    public static void Main(String[] args)    {          // double values whose logarithm         // to be calculated        double a = 4.55;        double b = 0;        double c = -2.45;        double nan = Double.NaN;        double positiveInfinity = Double.PositiveInfinity;             double negativeInfinity = Double.NegativeInfinity;          // Input is positive number so output        // will be logarithm of number        Console.WriteLine(Math.Log10(a));          // positive zero as argument, so output         // will be -Infinity        Console.WriteLine(Math.Log10(b));          // Input is negative number so output        // will be NaN        Console.WriteLine(Math.Log10(c));          // Input is NaN so output        // will be NaN        Console.WriteLine(Math.Log10(nan));          // Input is PositiveInfinity so output        // will be Infinity        Console.WriteLine(Math.Log10(positiveInfinity));          // Input is NegativeInfinity so output        // will be NaN        Console.WriteLine(Math.Log10(negativeInfinity));    }}
0.658011396657112
-Infinity
NaN
NaN
Infinity
NaN

Reference: https://msdn.microsoft.com/en-us/library/system.math.log10(v=vs.110).aspx
CSharp-Math
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker – Search Image in Dockerhub through CLI

05 Nov, 2020
There are tons of pre-built Docker Images that you can find on Docker’s official repository called DockerHub. In fact, you can also push your own customized Image on DockerHub. These Images can then be pulled using the Docker pull command and can be used as Base Images. In this article, we will discuss how you can search a Docker Image on DockerHub through Command Line Interface.
Note that in order to access DockerHub, you would need a DockerHub account and then you would have to log in to the DockerHub using your command line. You can do so by using the docker login command and then entering relevant details.
The general syntax of a Docker Search command is – 
sudo docker search <image-name>

For example, if you want to search Ubuntu images, you can use the following command.
sudo docker search ubuntu

The above command returns a list of images with similar names. It returns a list of images with parameters such as the Image name, the automated parameter suggests that you can build the Image automatically using platforms such as Github, etc. The Description parameter describes general information about the Image. The stars parameter displays the ratings given to it by the users and the official parameter suggests whether the Image is official or not.
You can also filter your search using the –filter option. For example, if you want to filter Ubuntu Images which has a minimum of 10 stars, you can use this command.
sudo docker search --filter=stars=10 ubuntu

To filter the search on the basis that the Image is automated or not, you can use this command.
sudo docker search --filter=is-automated=true ubuntu

To know more about the Docker Search Command and what other options it provides, you can use the –help option.
sudo docker search --help

–Filter: It filters the search output based on the conditions provided. We have already discussed how to use the Filter option.
–no-trunc : The output of the search command is usually truncated in order to avoid long descriptions. You can use this option to specify if you want truncated output or not.
–limit: You can use the flag to limit the number of search results.
–format: It displays output in a readable format.
Docker Container
linux
Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Monte Carlo Tree Search (MCTS)
Markov Decision Process
Basics of API Testing Using Postman
Copying Files to and from Docker Containers
Getting Started with System Design
Principal Component Analysis with Python
Monolithic vs Microservices architecture
Fuzzy Logic | Introduction
How to create a REST API using Java Spring Boot
OpenCV - Overview
Finding the index of the first repeating character in a string in JavaScript

We are required to write a JavaScript function that takes in a string and returns the index of the first character that appears twice in the string. If there is no such character then we should return -1.
Let’s say the following is our string −
const str = 'Hello world, how are you';
We need to find the index of the first repeating character.
The code for this will be −
const str = 'Hello world, how are you';
const firstRepeating = str => {
   const map = new Map();
   for(let i = 0; i < str.length; i++){
      if(map.has(str[i])){
         return map.get(str[i]);
      };
      map.set(str[i], i);
   };
   return -1;
};
console.log(firstRepeating(str));
The output in the console will be −
2
postconf - Unix, Linux Command

postconf [-aAmlv] [-c config_dir]


postconf [-ev] [-c config_dir]
[parameter=value ...]


postconf [-btv] [-c config_dir] [template_file]


Options:


This feature is available with Postfix 2.3 and later.


This feature is available with Postfix 2.3 and later.






The text below provides only a parameter summary. See
postconf(5) for more details including examples.

/etc/postfix/main.cf, Postfix configuration parameters

bounce(5), bounce template file format
postconf(5), configuration parameters



DATABASE_README, Postfix lookup table overview



Wietse Venema
IBM T.J. Watson Research
P.O. Box 704
Yorktown Heights, NY 10598, USA


Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
C# program to implement FizzBuzz

Implementation of FizzBuzz involves printing numbers from 1 to 100. If the numbers are multiples of 3 then Fizz is printed. If they are multiples of 5, then Buzz is printed and if they are multiples of both 3 and 5 then FizzBuzz is printed.
A program that demonstrates the implementation of FizzBuzz is given as follows.
 Live Demo
using System;
namespace FizzBuzzDemo {
   public class example {
      static void Main(string[] args) {
         for (int i = 1; i <= 100; i++) {
            if (i % 3 == 0 && i % 5 == 0) {
               Console.WriteLine("FizzBuzz");
            } else if (i % 3 == 0) {
               Console.WriteLine("Fizz");
            } else if (i % 5 == 0) {
               Console.WriteLine("Buzz");
            } else {
               Console.WriteLine(i);
            }
         }
      }
   }
}
The output of the above program is as follows.
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
41
Fizz
43
44
FizzBuzz
46
47
Fizz
49
Buzz
Fizz
52
53
Fizz
Buzz
56
Fizz
58
59
FizzBuzz
61
62
Fizz
64
Buzz
Fizz
67
68
Fizz
Buzz
71
Fizz
73
74
FizzBuzz
76
77
Fizz
79
Buzz
Fizz
82
83
Fizz
Buzz
86
Fizz
88
89
FizzBuzz
91
92
Fizz
94
Buzz
Fizz
97
98
Fizz
Buzz
Now, let us understand the above program.
A for loop runs from 1 to 100 and creates the numbers required. Then a series of if statements are used to find if the number i is divisible by 3, by 5 or by both. If the number is only divisible by 3, Fizz is printed. If the number is only divisible by 5, Buzz is printed and if the number is divisible by both, then FizzBuzz is printed. Otherwise, the number is printed. The code snippet for this is as follows −
for (int i = 1; i <= 100; i++) {
if (i % 3 == 0 && i % 5 == 0) {
Console.WriteLine("FizzBuzz");
}else if (i % 3 == 0) {
Console.WriteLine("Fizz");
} else if (i % 5 == 0) {
Console.WriteLine("Buzz");
} else {
Console.WriteLine(i);
}
}
Python Celsius to Fahrenheit

Theory of Computation
Suppose the Celsius lists are -
Celsius = [26.2, 33.2, 29.3, 32.4]
Such a type of program plays an important role in the most scientific applications, as it is the most widely used temperature scale throughout the world. The Fahrenheit scale is mostly used in the United States.
In the Celsius scale, the boiling point of water is 100°C, and the freezing point is at 0°C, while in the Fahrenheit scale the boiling point of water is measured at 212°F and freezing point at 32°F.
celsius * 1.8 = fahrenheit - 32
Lambda is an anonymous function that contains any number of arguments, but only one expression. 
	This function is defined without a name. 

lambda arguments: expression
Here, the arguments can be of any numbers, but the expression should be only one.
This is the following solution to calculate the Fahrenheit of the 
following Celsius list by using Lambda function.
Celsius = [26.2, 33.2, 29.3, 32.4]
Fahrenheit = map(lambda x: (float(9)/5)*x + 32, Celsius)
print Fahrenheit

In the above code, we have used the map() function. It accepts the name of a function in the first parameter
 and the Celsius sequence in the second parameter. The map() applies the function to convert Celsius to Fahrenheit
 to all the elements of the Celsius sequence. It returns a new list with the elements changed by the function.
Python - Check if all elements in a list are identical

There may be occasions when a list will contain all the values which are same. In this article we will see various way to verify that.
We use the all function to find the result of comparison of each element of the list with the first element. If each comparison gives a result of equality then the result is given as all elements are equal else all elements are not equal.
 Live Demo
listA = ['Sun', 'Sun', 'Mon']

resA = all(x == listA[0] for x in listA)

if resA:
   print("in ListA all elements are same")
else:
   print("In listA all elements are not same")
   
listB = ['Sun', 'Sun', 'Sun']
resB = all(x == listA[0] for x in listB)

if resB:
   print("In listB all elements are same")
else:
   print("In listB all elements are not same")
Running the above code gives us the following result −
In listA all elements are not same
In listB all elements are same
In this approach we count the number of occurrences of the first element and compare it with length of the elements in the list. If all elements are same then this length will match else it will not.
 Live Demo
listA = ['Sun', 'Sun', 'Mon']

resA = listA.count(listA[0]) == len(listA)

if resA:
   print("in ListA all elements are same")
else:
   print("In listA all elements are not same")

listB = ['Sun', 'Sun', 'Sun']
resB = listB.count(listB[0]) == len(listB)

if resB:
   print("In listB all elements are same")
else:
   print("In listB all elements are not same")  
Running the above code gives us the following result −
In listA all elements are not same
In listB all elements are same
Insert data from one schema to another in MySQL?

To insert data from one scheme to another, the syntax is as follows. Here, we have two databases “yourDatabaseName1” and “yourDatabaseName2” −
insert into yourDatabaseName2.yourTableName2 select *from yourDatabaseName1.yourTableName1;
To understand the above syntax, let us create a table. We are creating a table in database “web” −
mysql> create table DemoTable2020
   -> (
   -> Id int,
   -> Name varchar(20)
   -> );
Query OK, 0 rows affected (0.67 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable2020 values(101,'Chris');
Query OK, 1 row affected (0.12 sec)

mysql> insert into DemoTable2020 values(102,'David');
Query OK, 1 row affected (0.25 sec)

mysql> insert into DemoTable2020 values(103,'Mike');
Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable2020;
This will produce the following output −
+------+-------+
| Id   | Name  |
+------+-------+
| 101  | Chris |
| 102  | David |
| 103  | Mike  |
+------+-------+
3 rows in set (0.00 sec)
Here is the query to create second table in another database “test” −
mysql> use test;
Database changed
mysql> create table DemoTable2021
   -> (
   -> StudentId int,
   -> StudentName varchar(20)
   -> );
Query OK, 0 rows affected (0.60 sec)
Here is the query to MySQL inserting data from one schema to another −
mysql> insert into test.DemoTable2021 select *from web.DemoTable2020;
Query OK, 3 rows affected (0.18 sec)
Records: 3 Duplicates: 0 Warnings: 0
Display all records from the table using select statement −
mysql> select *from DemoTable2021;
This will produce the following output −
+-----------+-------------+
| StudentId | StudentName |
+-----------+-------------+
| 101       | Chris       |
| 102       | David       |
| 103       | Mike        |
+-----------+-------------+
3 rows in set (0.00 sec)
Batch Script - REN

Renames files and directories
ren [oldfile/dirname] [newfile/dirname]

Renames the file name from the old file/dir name to the new one.
@echo off 
ren C:\lists.txt C:\newlists.txt
The file lists.txt will be renamed to newlists.txt.
 Print
 Add Notes
 Bookmark this page
Implicit conversion from Int32 to Decimal in C#

The int type represents a 32-bit signed integer i.e. Int32.
To implicitly convert an Int32 to a Decimal, firstly set a Int32 value.
int val = 392;
To convert Int32 to decimal, assign the value.
decimal d;
d = val;
Let us see another example.
using System;
public class Demo {
   public static void Main() {
      int val = 767;
      decimal d;
      Console.WriteLine("Implicit conversion from Int32 (integer) to Decimal");
      d = val;
      Console.WriteLine("Decimal : "+dec);
   }
}
Find MongoDB records where array field is not empty?

You can use $ne(Not Equal) operator for this. To understand the concept, let us create a collection with document. The query to create a collection with document is as follows −
> db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"Larry","StudentTechnicalSubject":["Java","C"]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c76fe2f1e9c5dd6f1f78291")
}
> db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"Mike","StudentTechnicalSubject":[]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c76fe3b1e9c5dd6f1f78292")
}
> db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"Sam","StudentTechnicalSubject":["MongoDB"]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c76fe491e9c5dd6f1f78293")
}
> db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"Carol","StudentTechnicalSubject":[]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c76fe521e9c5dd6f1f78294")
}
> db.arrayFieldIsNotEmptyDemo.insertOne({"StudentName":"David","StudentTechnicalSubject":["MySQL","SQL Server"]});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5c76fe661e9c5dd6f1f78295")
}
Display all documents from a collection with the help of find() method. The query is as follows −
> db.arrayFieldIsNotEmptyDemo.find().pretty();
{
   "_id" : ObjectId("5c76fe2f1e9c5dd6f1f78291"),
   "StudentName" : "Larry",
   "StudentTechnicalSubject" : [
      "Java",
      "C"
   ]
}
{
   "_id" : ObjectId("5c76fe3b1e9c5dd6f1f78292"),
   "StudentName" : "Mike",
   "StudentTechnicalSubject" : [ ]
}
{
   "_id" : ObjectId("5c76fe491e9c5dd6f1f78293"),
   "StudentName" : "Sam",
   "StudentTechnicalSubject" : [
      "MongoDB"
   ]
}
{
   "_id" : ObjectId("5c76fe521e9c5dd6f1f78294"),
   "StudentName" : "Carol",
   "StudentTechnicalSubject" : [ ]
}
{
   "_id" : ObjectId("5c76fe661e9c5dd6f1f78295"),
   "StudentName" : "David",
   "StudentTechnicalSubject" : [
      "MySQL",
      "SQL Server"
   ]
}
Here is the query to find MongoDB records where array field is not empty −
> db.arrayFieldIsNotEmptyDemo.find({StudentTechnicalSubject:{$exists:true,$ne:[]}}).pretty();
{
   "_id" : ObjectId("5c76fe2f1e9c5dd6f1f78291"),
   "StudentName" : "Larry",
   "StudentTechnicalSubject" : [
      "Java",
      "C"
   ]
}
{
   "_id" : ObjectId("5c76fe491e9c5dd6f1f78293"),
   "StudentName" : "Sam",
   "StudentTechnicalSubject" : [
      "MongoDB"
   ]
}
{
   "_id" : ObjectId("5c76fe661e9c5dd6f1f78295"),
   "StudentName" : "David",
   "StudentTechnicalSubject" : [
      "MySQL",
      "SQL Server"
   ]
}
Kotlin Ranges

With the for loop, you can also create 
ranges of values with "..":
Print the whole alphabet:
for (chars in 'a'..'x') {
  println(chars)
}
You can also create ranges of numbers:
for (nums in 5..15) {
  println(nums)
} 
Note: The first and last value is included in the range.
You can also use the in operator to check if a value exists in 
a range:
val nums = arrayOf(2, 4, 6, 8)
if (2 in nums) {
  println("It exists!")
} else {
  println("It does not exist.")
}
val cars = arrayOf("Volvo", "BMW", "Ford", "Mazda")
if ("Volvo" in cars) {
  println("It exists!")
} else {
  println("It does not exist.")
} 
You can also use the break and continue keywords in a range/for loop:
Stop the loop when nums is equal to 10:
for (nums in 5..15) {
  if (nums == 10) {
    break
  }
  println(nums)
} 
Skip the value of 10 in the loop, and continue with the next iteration:
for (nums in 5..15) {
  if (nums == 10) {
    continue
  }
  println(nums)
} 
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.
C++ Program to Perform the Shaker Sort

Shaker sort is used to sort the given data. Shaker sort, unlike Bubble sort, orders the array in both directions. The worst complexity of this algorithm is O(n^2).
Begin
   ShakerSort() function has ‘arr’ the array of data and ‘n’ the number of values, in the argument list.
   // Implement Sorting algorithm using nested for loops.
   The parent loop will run on ‘i’ from 0 to n-1 and contains two loops inside.
   The first loop will run on ‘j’ from i+1 to n-1 and use swap() if a[j] < a[j-1].
   Decrement n.
   The second loop will run on 'k' from m-1 to i+1 and use swap() if a[k] < a[k-1].
   Increment i.
End
#include<iostream>
using namespace std;
void swap(int *a, int *b) {
   int temp;
   temp = *a;
   *a = *b;
   *b = temp;
}
void ShakerSort(int a[], int m) {
   int i, j, k;
   for(i = 0; i < m;) {
      for(j = i+1; j < m; j++) {
         if(a[j] < a[j-1])
            swap(&a[j], &a[j-1]);
      }
      m--;
      for(k = m-1; k > i; k--) {
         if(a[k] < a[k-1])
            swap(&a[k], &a[k-1]);
      }
      i++;
   }
}
int main() {
   int n, i;
   cout<<"\nEnter the number of data element to be sorted: ";
   cin>>n;
   int a[n];
   for(i = 0; i < n; i++) {
      cout<<"Enter element "<<i+1<<": ";
      cin>>a[i];
   }
   ShakerSort(a, n);
   cout<<"\nSorted Data ";
   for (i = 0; i < n; i++)
      cout<<"->"<<a[i];
   return 0;
}
Enter the number of data element to be sorted: 4
Enter element 1: 3
Enter element 2: 1
Enter element 3: 7
Enter element 4: 6
Sorted Data ->1->3->6->7
Underscore.js _.values() Function - GeeksforGeeks

25 Nov, 2021
The _.values() function is used to return the list of all values of the object element.
Syntax:
_.values( object )
Parameters: This function accepts one parameter as mentioned above and described below:
object: It contains the object element that holds the elements of key and value pair.
Return Value: It returns the list of all values of the object element.
Example 1:
<!DOCTYPE html><html>  <head>    <script type="text/javascript"             src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js">    </script></head>  <body>    <script type="text/javascript">          var obj = {            Company: "GeeksforGeeks",            Address: "Noida",            Contact: "+91 9876543210",            Email: "abc@gfg.com"        }        console.log(_.values(obj));    </script></body>  </html>
Output:
Example 2:
<!DOCTYPE html><html>  <head>    <script type="text/javascript"             src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js">    </script></head>  <body>    <script type="text/javascript">          var key = _.values({            Name: "Ashok",            Address: "Noida",            Mobile: "+91 9876543210",            Email: "geeks@gmail.com"        });          console.log(key);    </script></body>  </html>
Output:
JavaScript - Underscore.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
File uploading in React.js
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
Initialization of a normal array with one default value in C++

The entire array can be initialized to zero very simply. This is shown below.
int arr[10] = {0};
However, it is not possible to initialize the entire array to a non-zero value using the above method. This is shown below.
int arr[10] = {5};
In the above example, only the first element will be initialized to 5. All others are initialized to 0.
A for loop can be used to initialize an array with one default value that is not zero. This is shown below.
for(i = 0; i<10; i++) {
   arr[i] = 5;
}
In the above example, all the array elements are initialized to 5.
A program that demonstrates all the above examples is given as follows.
 Live Demo
#include <iostream>
using namespace std;
int main() {
   int a[10] = {0};
   int b[10] = {5};
   int c[10];
   for(int i = 0; i<10; i++) {
      c[i] = 5;
   }
   cout<<"Elements of array a: ";
   for(int i = 0; i<10; i++) {
      cout<< a[i] <<" ";
   }
   cout<<"\n";
   cout<<"Elements of array b: ";
   for(int i = 0; i<10; i++) {
      cout<< b[i] <<" ";
   }
   cout<<"\n";
   cout<<"Elements of array c: ";
   for(int i = 0; i<10; i++) {
      cout<< c[i] <<" ";
   }
   cout<<"\n";
   return 0;
}
The output of the above program is as follows.
Elements of array a: 0 0 0 0 0 0 0 0 0 0
Elements of array b: 5 0 0 0 0 0 0 0 0 0
Elements of array c: 5 5 5 5 5 5 5 5 5 5
numpy.shares_memory() function – Python - GeeksforGeeks

08 Jul, 2020
numpy.shares_memory() function determine if two arrays share memory.
Syntax : numpy.shares_memory(arr1, arr2, max_work = None)Parameters :arr1, arr2 : [ndarray] Input arrays.max_work : [int, optional] Effort to spend on solving the overlap problem.Return : [bool] Checking if two arrays share memory.
Code #1 :
# Python program explaining# numpy.shares_memory() function            # importing numpy as geek import numpy as geek    arr1 = geek.array([1, 2, 3, 4])arr2 = geek.array([5, 6, 7])  gfg = geek.shares_memory(arr1, arr2)      print (gfg)
Output :
False

 Code #2 :
# Python program explaining# numpy.shares_memory() function            # importing numpy as geek import numpy as geek    arr1 = geek.array([1, 2, 3, 4])arr2 = arr1[::2]  gfg = geek.shares_memory(arr1, arr2)      print (gfg)
Output :
True

Python-numpy
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 drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Create a directory in Python
Python | Pandas dataframe.groupby()
Can we assign values to final arrays in Java?

The array is a container that can hold a fixed number of items and these items should be of the same type. Most of the data structures make use of arrays to implement their algorithms. The following are the important terms to understand the concept of Array.
Element − Each item stored in an array is called an element.
Element − Each item stored in an array is called an element.
Index − Each location of an element in an array has a numerical index, which is used to identify the element.
Index − Each location of an element in an array has a numerical index, which is used to identify the element.
The size of the array will be determined at the time of creation.
 Live Demo
public class ArrayExample {
   public static void main(String args[]){
      //Declaring an array
      int[] myArray = {233, 783, 453};
      //Printing the array
      for(int i=0; i<myArray.length; i++){
         System.out.println(myArray[i]);
      }
   }
}
233
783
453
If you declare a final variable later on you cannot modify or, assign values to it. Moreover, like instance variables, final variables will not be initialized with default values.
Therefore, it is mandatory to initialize final variables once you declare them.
Still, if you try to declare final variables without initialization that will generate a compilation error saying “variable variable_name not initialized in the default constructor”.
public class FinalVariables {
   public static void main(String args[]){
      final int j = 10;
      j = 220;
   }
}
But in case of arrays you can declare arrays final and still can reassign values to it without any compile-time errors.
 Live Demo
public class FinalArrays {
   public static void main(String args[]){
      //Declaring an array
      final int[] myArray = {233, 783, 453};
      //Printing the array
      for(int i=0; i<myArray.length; i++){
         System.out.println(myArray[i]);
      }
      //Changing the values of the array
      myArray[0] = 2020;
      myArray[1] = 3040;
      myArray[2] = 4060;
      for(int i=0; i<myArray.length; i++){
         System.out.println(myArray[i]);
      }
   }
}
233
783
453
2020
3040
4060
The reason for this is unlike variables, arrays are objects and they do not hold values instead, they point to the address of the locations that hold values.
In the case of objects and arrays if a reference variable is final it cannot point to another object/array. If you try to do so a compile-time error is generated.
 Live Demo
public class FinalArrays {
   public static void main(String args[]){
      //Declaring an array
      final int[] myArray1 = {233, 783, 453};
      //Printing the array
      System.out.println(myArray1);
      int[] myArray2 = {233, 783, 453};
      myArray2[0] = 2020;
      myArray2[1] = 3040;
      myArray2[2] = 4060;
      myArray1 = myArray2;
   }
}
inalArrays.java:14: error: cannot assign a value to final variable myArray1
   myArray1 = myArray2;
   ^
1 error
React Native - Styling

There are a couple of ways to style your elements in React Native.
You can use the style property to add the styles inline. However, this is not the best practice because it can be hard to read the code.
In this chapter, we will use the Stylesheet for styling.
In this section, we will simplify our container component from our previous chapter.
App.js
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import PresentationalComponent from './PresentationalComponent'

export default class App extends React.Component {
   state = {
      myState: 'This is my state'
   }
   render() {
      return (
         <View>
            <PresentationalComponent myState = {this.state.myState}/>
         </View>
      );
   }
}
In the following example, we will import the StyleSheet. At the bottom of the file, we will create our stylesheet and assign it to the styles constant. Note that our styles are in camelCase and we do not use px or % for styling.
To apply styles to our text, we need to add style = {styles.myText} property to the Text element.
PresentationalComponent.js
import React, { Component } from 'react'
import { Text, View, StyleSheet } from 'react-native'

const PresentationalComponent = (props) => {
   return (
      <View>
         <Text style = {styles.myState}>
            {props.myState}
         </Text>
      </View>
   )
}
export default PresentationalComponent

const styles = StyleSheet.create ({
   myState: {
      marginTop: 20,
      textAlign: 'center',
      color: 'blue',
      fontWeight: 'bold',
      fontSize: 20
   }
})
When we run the app, we will receive the following output.

    20 Lectures 
     1.5 hours 

 Anadi Sharma

    61 Lectures 
     6.5 hours 

 A To Z Mentor

    40 Lectures 
     4.5 hours 

 Eduonix Learning Solutions

    56 Lectures 
     12.5 hours 

 Eduonix Learning Solutions

    62 Lectures 
     4.5 hours 

 Senol Atac

    67 Lectures 
     4.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
Set style for Labelframe in Python Tkinter

Tkinter LabelFrame is similar to Frames in Tkinter Library. It works like a container where widgets can be placed. LabelFrame initially creates a container with some rectangular border around it. In order to style the LabelFrame widget, we have several style options such as background, borderwidth, labelanchor, highlightcolor and many more.
In this example, we will see the LabelFrame widget and its properties.
#Import required libraries
from tkinter import *
#Create an instance of tkinter frame
win= Tk()
#Define the geometry of the window
win.geometry("750x250")
#Initialize a LabelFrame Widget
labelframe= LabelFrame(win, text= "Frame 01",width= 600, height= 200, labelanchor= "n", font= ('Helvetica 14 bold'),bd= 5, background="gray71", foreground= "white")
labelframe.pack(ipadx=10, ipady=20, expand= True, fill= BOTH)

#Create a Label inside LabelFrame
Label(labelframe, text= "I am inside a LabelFrame", font=('Helvetica15 bold'), foreground= "black").pack(pady= 20)

win.mainloop()
Running the above code will display a window that contains a labelframe with borderwidth of 5px.
Creating Python Virtual Environment in Windows and Linux - GeeksforGeeks

09 Feb, 2018
A Virtual Environment is a python environment, that is an isolated working copy of Python which allows you to work on a specific project without affecting other projectsSo basically it is a tool that enables multiple side-by-side installations of Python, one for each project.
Creating virtual environment in Linux
If pip is not in your system
$ sudo apt-get install python-pip
Then install virtualenv
$ pip install virtualenv
Now check your installation
$ virtualenv --version
Create a virtual environment now,
$ virtualenv virtualenv_name
After this command, a folder named virtualenv_name will be created. You can name anything to it. If you want to create a virtualenv for specific python version, type
$ virtualenv -p /usr/bin/python3 virtualenv_name
or
$ virtualenv -p /usr/bin/python2.7 virtualenv_name
Now at last we just need to activate it, using command
$ source virtualenv_name/bin/activate
Now you are in a Python virtual environment
You can deactivate using
$ deactivate
Creating Python virtualenv in Windows
If python is installed in your system, then pip comes in handy.So simple steps are:1) Install virtualenv using
 > pip install virtualenv 
2)Now in which ever directory you are, this line below will create a virtualenv there
 > virtualenv myenv
And here also you can name it anything.
3) Now if you are same directory then type,
 > myenv\Scripts\activate
You can explicitly specify your path too.
Similarly like Linux you can deactivate it like
$ deactivate
GBlog
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Front End Developer Skills That You Need in 2022
DSA Sheet by Love Babbar
6 Best IDE's For Python in 2022
GET and POST requests using Python
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Java Program to parse a mathematical expression and operators

At first, we have set the mathematical expressions:
String one = "10+15*20-5/5";
String two = "3+5-6";
String three = "9+2*(6-3+7)";
To parse mathematical expression, use Nashorn JavaScript in Java i.e. scripting. Nashorn invoke
dynamics feature, introduced in Java 7 to improve performance.
For scripting, use the ScriptEngineManager class for the engine:
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("Nashorn");
Now for JavaScript code from string, use eval i.e. execute the script. Here, we are parsing mathematical expressions set above:
Object expResult1 = scriptEngine.eval(one);
Object expResult2 = scriptEngine.eval(two);
Object expResult3 = scriptEngine.eval(three);
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
public class Demo {
   public static void main(String[] args) throws Exception {
      String one = "10+15*20-5/5";
      String two = "3+5-6";
      String three = "9+2*(6-3+7)";
      String four = "(10 % 3)*2+6";
      String five = "3*3+3";
      ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
      ScriptEngine scriptEngine = scriptEngineManager.getEngineByName("Nashorn");
      Object expResult1 = scriptEngine.eval(one);
      Object expResult2 = scriptEngine.eval(two);
      Object expResult3 = scriptEngine.eval(three);
      Object expResult4 = scriptEngine.eval(four);
      Object expResult5 = scriptEngine.eval(five);
      System.out.println("Result of expression1 = " + expResult1);
      System.out.println("Result of expression2 = " + expResult2);
      System.out.println("Result of expression3 = " + expResult3);
      System.out.println("Result of expression4 = " + expResult4);
      System.out.println("Result of expression5 = " + expResult5);
   }
}
Result of expression1 = 309
Result of expression2 = 2
Result of expression3 = 29
Result of expression4 = 8
Result of expression5 = 12
How to new line string - JavaScript?

Use <br> tag for a new line.
Following is the code −
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Document</title>
</head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<body>
   <h1 id="headingDemo">
      My Name is David Miller
   </h1>
</body>
<script>
   document.getElementById("headingDemo").innerHTML = "My Favourite Subject is JavaScript" + '<br>' + "I live in AUS.";
</script>
</html>
To run the above program, save the file name anyName.html (index.html). Right click on the file and select the option “Open with Live Server” in VS Code editor.
The output is as follows −
Batch Script - Empty String

An empty string can be created in DOS Scripting by assigning it no value during it’s initialization as shown in the following example.
Set a=

To check for an existence of an empty string, you need to encompass the variable name in square brackets and also compare it against a value in square brackets as shown in the following example.
[%a%]==[]

The following example shows how an empty string can be created and how to check for the existence of an empty string.
@echo off 
SET a= 
SET b=Hello 
if [%a%]==[] echo "String A is empty" 
if [%b%]==[] echo "String B is empty "
The above command produces the following output.
String A is empty

 Print
 Add Notes
 Bookmark this page
Change Primary Key Column in SQL Server - GeeksforGeeks

23 Sep, 2021
Primary Key refers to the column of a table that uniquely identifies a row in a table. It contains unique values and can not contain NULL values. For the purpose of the demonstration, we will be creating geeks for geeks table in a database called “geeks“.
Step 1: Creating the database 
The database is created in SQL Server using the following command 
Query:
CREATE DATABASE geeks;
Step 2: Using the Database
Use the below SQL statement to switch the database context to geeks:
Query:
USE geeks;
In SQL Server, the Primary key constraint is defined by the syntax:
Syntax:
CREATE TABLE tablename (
column_name datatype NOT
NULL PRIMARY KEY);
We can also define the primary key after making the table, but make sure the column has the NOT NULL constraint on it. The syntax for declaring primary key after defining the table:
Syntax:
Alter table table_name add  primary key (column_name);
To change the Primary key column in the SQL Server, follow these steps:
Drop already defined primary key.
Add a new column as the primary key.
Step 1: Table creation
We have the following geeks for geeks table in the geeks database
Query:
CREATE TABLE geeksforgeeks(
ID int PRIMARY KEY,
FIRSTNAME varchar(30),
LASTNAME varchar(30),
CITY varchar(18),
EmpID int NOT NULL
);
Step 2: Insert data into the table
Query:
INSERT INTO geeksforgeeks VALUES 
(1,'Romy', 'Kumari', 'Delhi',1900089),
(2,'Avinav', 'Pandey', 'Delhi',1909089),
(3,'Nikhil', 'Kalra', 'Punjab',1000089),
(4,'Mansi', 'Lal', 'Uttarpradesh',1905689),
(5,'Rinkle', 'Arora', 'Haryana',1900989),
(6,'Sakshi', 'Kumari', 'Delhi',1700089),
(7,'Soumya', 'Shriya', 'Bihar',1660089),
(8,'Mitu', 'Kumari', 'Rajasthan',1340089);
Step 3: Check the content of table
Query:
SELECT * FROM geeksforgeeks;
Output:
Query:
SELECT * FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE  ;
Output:
In the above figure, you can see ID column is the primary key. We can drop this primary key by using the CONSTRAINT_NAME mentioned in the image. From here copy CONSTRAINT_NAME to drop the primary key.
Query:
ALTER TABLE geeksforgeeks DROP CONSTRAINT PK__geeksfor__3214EC275032BA6D;
Add EmpID as new Primary key (always check NOT NULL constraint is specified, otherwise, an error will be thrown)
Query:
ALTER TABLE geeksforgeeks ADD PRIMARY KEY (EmpID);
Now check the primary key of the table using ‘SELECT * FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ‘  command
Output:
In the above image, you can see EMPID is the primary key.
Blogathon-2021
Picked
SQL-Server
Blogathon
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install Numpy on MacOS?
Dart - Null Aware Operators
Format Dates in Flutter
How to Install Tkinter in Windows?
Designing algorithm to solve Ball Sort Puzzle
SQL | DDL, DQL, DML, DCL and TCL Commands
SQL | Join (Inner, Left, Right and Full Joins)
SQL | WITH clause
How to find Nth highest salary from a table
SQL Correlated Subqueries
Difference between Dependency Injection and Factory Pattern.

Factory and Dependency injection both are the design pattern which can be used to enhance loose coupling abilities between the software components. 
Factory design pattern is used to create objects. But, injection and life cycle management of the object should be handled by programmer within the application. There is no way to configure everything in a single place. Therefore, programmers need to call object creation logic wherever it needed which eventually hinder the loose coupling abilities.
In DI design pattern, creation of object, injecting of the instance and life cycle management of the instance can be handled outside the code. In spring, Instantiation ,Injection and Lifecycle management are handled by IOC container.
static class PizzaFactory{
   public Pizza buildPizza(String pizzaType){
      ........

      Pizza pizza= //create pizza based on type
      return pizza;
   }
}
static void Main(){
   Pizza pizza = PizzaFactory.buildPizza("Greek style");
}
public class CustomerExample {
   public Address address
   public CustomerExample(Address address) {
      this.address = address;
   }
}
public class Address {
   ..............
}
Impala - Select a Database

Once you get connected to Impala, it is required to select one among the available databases. The USE DATABASE Statement of Impala is used to switch the current session to another database.
Following is the syntax of USE Statement.
USE db_name;

Following is an example of USE statement. First of all, let us create a database with the name sample_database as shown below.
> CREATE DATABASE IF NOT EXISTS sample_database;

This will create a new database and give you the following output.
Query: create DATABASE IF NOT EXISTS my_db2

Fetched 0 row(s) in 2.73s

If you verify the list of databases using the SHOW DATABASES statement, you can observe the name of newly created database in it.
> SHOW DATABASES;

Query: show DATABASES 
+-----------------------+ 
| name                  | 
+-----------------------+ 
| _impala_builtins      | 
| default               | 
| my_db                 | 
| sample_database       | 
+-----------------------+ 
Fetched 4 row(s) in 0.11s
Now, let’s switch the session to the newly created database (sample_database) using the USE Statement as shown below.
> USE sample_database;

This will change the current context to sample_database and display a message as shown below.
Query: use sample_database

On the left-hand side of the Query Editor of Impala, you will find a dropdown menu as shown in the following screenshot.
If you click on the dropdown menu, you will find the list of all the databases in Impala as shown below.
Simply select the database to which you need to change the current context.
 Print
 Add Notes
 Bookmark this page