code-rag-bench/online-tutorials huggingface dataset:
Requests - Working with Cookies

This chapter will discuss how to deal with cookies. You can get the cookies as well as send your cookies while calling the URL using the requests library.
The url, https://jsonplaceholder.typicode.com/users when hits in the browser we can get the details of the cookies as shown below −
You can read the cookies as shown below −
import requests
getdata = requests.get('https://jsonplaceholder.typicode.com/users')
print(getdata.cookies["__cfduid"])
E:\prequests>python makeRequest.py
d1733467caa1e3431fb7f768fa79ed3741575094848

You can also send cookies when we make a request.
import requests
cookies = dict(test='test123')
getdata = requests.get('https://httpbin.org/cookies',cookies=cookies)
print(getdata.text)
E:\prequests>python makeRequest.py
{
   "cookies": {
      "test": "test123"
   }
}

 Print
 Add Notes
 Bookmark this page
Setting a relative frequency in a Matplotlib histogram

To set a relative frequency in a matplotlib histogram, we can take the following steps −
Create a list of numbers for data and bins.
Create a list of numbers for data and bins.
Compute the histogram of a set of data, using histogram() method.
Compute the histogram of a set of data, using histogram() method.
Get the hist and edges from the histogram.
Get the hist and edges from the histogram.
Find the frequency of the histogram.
Find the frequency of the histogram.
Make a bar with bins (step 1) and freq data (step 4).
Make a bar with bins (step 1) and freq data (step 4).
To display the figure, use show() method.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
a = [-0.125, .15, 8.75, 72.5, -44.245, 88.45]
bins = np.arange(-180, 181, 20)
hist, edges = np.histogram(a, bins)
freq = hist/float(hist.sum())
plt.bar(bins[:-1], freq, width=20, align="edge", ec="k", color='red')
plt.show()
Set position with seekg() in C++ language file handling

seekg() is a function in the iostream library that allows us to seek an arbitrary position in a file. It is mainly used to set the position of the next character to be extracted from the input stream from a given file in C++ file handling.
istream&seekg(streamoff offset, ios_base::seekdir dir);
istream&seekg(streampos position);
Where,
position: It is the new position in the stream buffer.
offset: It is an integer value of type streamoff which represents the offset in the stream’s buffer, relative to the dir parameter.
dir: It is the seeking direction. It is an object of type ios_base::seekdir that can take any offset constant value.

Three direction used for offset values are:
ios_base::beg = from the beginning of the stream’s buffer.
ios_base::cur = from the current position in the stream’s buffer.
ios_base::end = from the end of the stream’s buffer.
Required steps and operations
Begin
   Open a data file for input/output operations.
   Add ‘TutorialsPoint’ to the file.
   Seek to 9 position from beginning of the file.
   Read the next 5 characters from the file into buffer F.
   End F with null character as terminator character.
   Print the contents.
   Close the file.
End
#include <fstream>
#include <iostream>
using namespace std;
int main (int argc, char** argv) {
   fstream File("d.txt", ios::in | ios::out );
   File << "TutorialsPoint";
   File.seekg(9, ios::beg);
   char F[9];
   File.read(F, 5);
   F[5] = 0;
   cout <<F<< endl;
   File.close();
}
Point
How to calculate sum of array elements using pointers in C language?

Pointer is a variable which stores the address of other variable.
Consider the following statement −
int qty = 179;
The syntax for declaring a pointer is as follows −
int *p;
Here, ‘p’ is a pointer variable which holds the address of other variable.
Address operator (&) is used to initialize a pointer variable.
For example,
int qty = 175;
int *p;
p= &qty;
It is collection of addresses (or) collection of pointers.
Following is the declaration for array of pointers −
datatype *pointername [size];
For example,
int *p[5];
It represents an array of pointers that can hold five integer element addresses.
‘&’ is used for initialization
For example,
int a[3] = {10,20,30};
int *p[3], i;
for (i=0; i<3; i++) (or) for (i=0; i<3,i++)
p[i] = &a[i];
p[i] = a+i;
Indirection operator (*) is used for accessing.
For example,
for (i=0, i<3; i++)
printf ("%d", *p[i]);
Following is the C program to calculate the sum of the array elements by using pointers −
 Live Demo
//sum of array elements using pointers
#include <stdio.h>
#include <malloc.h>
void main(){
   int i, n, sum = 0;
   int *ptr;
   printf("Enter size of array : \n");
   scanf("%d", &n);
   ptr = (int *) malloc(n * sizeof(int));
   printf("Enter elements in the List \n");
   for (i = 0; i < n; i++){
      scanf("%d", ptr + i);
   }
   //calculate sum of elements
   for (i = 0; i < n; i++){
      sum = sum + *(ptr + i);
   }
   printf("Sum of all elements in an array is = %d\n", sum);
   return 0;
}
When the above program is executed, it produces the following result −
Enter size of array:
5
Enter elements in the List
12
13
14
15
16
Sum of all elements in an array is = 70
How to display all label values in Matplotlib?

To display all label values, we can use set_xticklabels() and set_yticklabels() methods.
Create a list of numbers (x) that can be used to tick the axes.
Create a list of numbers (x) that can be used to tick the axes.
Get the axis using subplot() that helps to add a subplot to the current figure.
Get the axis using subplot() that helps to add a subplot to the current figure.
Set the ticks on X and Y axes using set_xticks and set_yticks methods respectively and list x (from step 1).
Set the ticks on X and Y axes using set_xticks and set_yticks methods respectively and list x (from step 1).
Set tick labels with label lists (["one", "two", "three", "four"]) and rotation of 45 using set_xticklabels() and set_yticklabels().
Set tick labels with label lists (["one", "two", "three", "four"]) and rotation of 45 using set_xticklabels() and set_yticklabels().
To add space between axes and tick labels, we can use tick_params() method with pad argument that helps to add space. Argument direction (in) helps to put ticks inside the axes, and axis (both), parameters to be applied on both the axes.
To add space between axes and tick labels, we can use tick_params() method with pad argument that helps to add space. Argument direction (in) helps to put ticks inside the axes, and axis (both), parameters to be applied on both the axes.
To show the figure, use plt.show() method.
To show the figure, use plt.show() method.
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = [1, 2, 3, 4]
ax1 = plt.subplot()
ax1.set_xticks(x)
ax1.set_yticks(x)
ax1.set_xticklabels(["one", "two", "three", "four"], rotation=45)
ax1.set_yticklabels(["one", "two", "three", "four"], rotation=45)
ax1.tick_params(axis="both", direction="in", pad=15)
plt.show()
How to implement constants in java?

A constant variable is the one whose value is fixed and only one copy of it exists in the program. Once you declare a constant variable and assign value to it, you cannot change its value again throughout the program.
You can create a constant in c language using the constant keyword (one way to create it) as −
const int intererConstant = 100;
or,
const float floatConstant = 16.254;
..... etc
Unlike in C language constants are not supported in Java(directly). But, you can still create a constant by declaring a variable static and final.
Static − Once you declare a variable static they will be loaded in to the memory at the compile time i.e. only one copy of them is available.
Final − once you declare a variable final you cannot modify its value again.
Therefore, you can create a constant in Java by declaring the instance variable static and final.
In the following Java example, we have 5 constants (static and final variables) in a class (named Data) and, accessing them from the main method of another class.
class Data{
   static final int integerConstant = 20;
   static final String stringConstant = "hello";
   static final float floatConstant = 1654.22f;
   static final char characterConstant = 'C';
}
public class ConstantsExample {
   public static void main(String args[]) {
      System.out.println("value of integerConstant: "+Data.integerConstant);
      System.out.println("value of stringConstant: "+Data.stringConstant);
      System.out.println("value of floatConstant: "+Data.floatConstant);
      System.out.println("value of characterConstant: "+Data.characterConstant);
   }
}
value of integerConstant: 20
value of stringConstant: hello
value of floatConstant: 1654.22
value of characterConstant: C
JavaScript function to convert Indian currency numbers to words with paise support

We are required to write a JavaScript function that takes in a floating-point number up to 2 digits of precision.
The function should convert that number into the Indian current text.
For example −
If the input number is −
const num = 12500
Then the output should be −
const output = 'Twelve Thousand Five Hundred';
Following is the code −
const num = 12500;
const wordify = (num) => {
   const single = ["Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"];
   const double = ["Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"];
   const tens = ["", "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
   const formatTenth = (digit, prev) => {
      return 0 == digit ? "" : " " + (1 == digit ? double[prev] : tens[digit])
   };
   const formatOther = (digit, next, denom) => {
      return (0 != digit && 1 != next ? " " + single[digit] : "") + (0 != next || digit > 0 ? " " + denom : "")
   };
   let res = "";
   let index = 0;
   let digit = 0;
   let next = 0;
   let words = [];
   if (num += "", isNaN(parseInt(num))){
      res = "";
   }
   else if (parseInt(num) > 0 && num.length <= 10) {
      for (index = num.length - 1; index >= 0; index--) switch (digit = num[index] - 0, next = index > 0 ? num[index - 1] - 0 : 0, num.length - index - 1) {
         case 0:
            words.push(formatOther(digit, next, ""));
         break;
         case 1:
            words.push(formatTenth(digit, num[index + 1]));
            break;
         case 2:
            words.push(0 != digit ? " " + single[digit] + " Hundred" + (0 != num[index + 1] && 0 != num[index + 2] ? " and" : "") : "");
            break;
         case 3:
            words.push(formatOther(digit, next, "Thousand"));
            break;
         case 4:
            words.push(formatTenth(digit, num[index + 1]));
            break;
         case 5:
            words.push(formatOther(digit, next, "Lakh"));
            break;
         case 6:
            words.push(formatTenth(digit, num[index + 1]));
            break;
         case 7:
            words.push(formatOther(digit, next, "Crore"));
            break;
         case 8:
            words.push(formatTenth(digit, num[index + 1]));
            break;
         case 9:
            words.push(0 != digit ? " " + single[digit] + " Hundred" + (0 != num[index + 1] || 0 != num[index + 2] ? " and" : " Crore") : "")
      };
      res = words.reverse().join("")
   } else res = "";
   return res
};
console.log(wordify(num));
Following is the output on console −
Twelve Thousand Five Hundred
Check if string ends with a specified suffix in Julia - endswith() Method - GeeksforGeeks

26 Mar, 2020
The endswith() is an inbuilt function in julia which is used to return true if the specified string ends with the specified suffix value else return false.
Syntax:endswith(s::AbstractString, suffix::AbstractString)
Parameters:
s::AbstractString: Specified string.
suffix::AbstractString: Specified suffix value.
Returns: It returns true if the specified string ends with the specified suffix else return false.
Example 1:
# Julia program to illustrate # the use of String endswith() method  # Checking ending part of string with # specified suffix valueprintln(endswith("Geeks", "ks"))println(endswith("GeeksforGeeks", "forGeeks"))println(endswith("GFG", "FG"))
Output:
true
true
true
Example 2:
# Julia program to illustrate # the use of String endswith() method  # Checking ending part of string with # specified suffix valueprintln(endswith("Geeks", "Geek"))println(endswith("GeeksforGeeks", "Geek"))println(endswith("GFG", "GF"))
Output:
false
false
false
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Searching in Array for a given element in Julia
Get array dimensions and size of a dimension in Julia - size() Method
Get number of elements of array in Julia - length() Method
Decision Making in Julia (if, if-else, Nested-if, if-elseif-else ladder)
Getting the maximum value from a list in Julia - max() Method
Find maximum element along with its index in Julia - findmax() Method
Exception handling in Julia
Getting the absolute value of a number in Julia - abs() Method
Reverse array elements in Julia - reverse(), reverse!() and reverseind() Methods
Working with Date and Time in Julia
How to get current date and time from internet in iOS?

Working with date and time can be tricky, I’ve seen new programmers struggling with date and time. In almost all the application you will be required to get the date and multiple operations are dependent on it.
Here we will be seeing how to get the current date and time in swift.
In this post we will be seeing how to get the current time and UTC time.
For getting the UTC time, paste below code in playground.
let utcDate = Date()
print(utcDate)
If you wish to get the time stamp of your location, paste the below code in playground.
let dateObj = Date()
let datetformatter = DateFormatter()
datetformatter.timeZone = TimeZone.current
datetformatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
print(datetformatter.string(from: dateObj))
Datameer — Simple transformations | by Prathamesh Nimkar | Towards Data Science

One of my data engineering team members was working on a new requirement from the business. And he happened to encounter a relatively new SaaS tool from an already established data player, “Datameer”.
The tool is fairly new and supports “drag and drop” functionality.
Anyway, let’s get started. First off, let me show you some of the sample data I am working with today. I have two tables, 1 dimension and 1 fact within my Snowflake database account.
D_Tracks:
F_Streams:
The goal today is to simply find how many times a track has been streamed every day. Technically, we just need three columns i.e., the date, the track name, and the counts. Furthermore, we want only those, which have been played more than once every day — we’re interested in the popularity of a song.
Assuming you have configured Snowflake with Datameer SaaS, let’s see how easy it is to represent/or implement a solution to the above requirement:
Step 1: Bring the datasets into Datameer SaaS tool
Step 2: Click the “New Transformation” button and select “Formula”
Step 3: Convert Time_Stamp into Dates
When prompted select “Time_Stamp” column and enter the following formula:
TO_DATE(Source.TIME_STAMP)
Step 4: Rename the new “Recipe” with “F_STREAMS_WITH_DATES”
Step 5: Click the new transformation button after “F_STREAMS_WITH_DATES” and select “Blend” this time
Please note, we are trying to perform an inner join between “F_STREAMS_WITH_DATES” and “D_TRACKS” on the “Tracks_Key” column.
In order to do so, please perform the following:
This will help us to create a new “Recipe” — “F_STREAMS_DATES_WITH_TRACKS” as in the next flow image.
Step 6: Add a new aggregate transformation now
The idea is to group the records by dates and track names. Also we will create a counts column that will help us filter out records which have been played less than two times.
For achieving the above, simply go through the following image:
It is important to note that the data looks like the following now:
Step 7: Let’s remove data where counts ≤ 1
Be sure to select the “Filter” transformation this time.
Very simply, add a new filter to the dataset and return records only for counts greater than 1.
Step 8: Order the records based on dates
Lastly, we need to select the “SQL” transformation to write standard ANSI SQL on our recipes and return results ordered by Dates in ascending order.
Our flow currently looks like the below:
This is done as below:
select * from F_STREAMS_DATES_TRACKS_AGG_G1 AS FG1ORDER BY FG1.TIME_STAMP;
The final data set of 32 records looks as below:
Now if we wanted to write the entire SQL code, we could always do the following from within the SQL input option in the same tool:
SELECT TO_DATE(FS.Time_Stamp) as Stream_Date, DT.Track_Name, COUNT(FS.Streams_Key)FROM EDW.FACTS.F_STREAMS as FSINNER JOIN EDW.DIMS.D_Tracks DT ON FS.Tracks_Key = DT.Tracks_KeyGROUP BY TO_DATE(FS.Time_Stamp), DT.Track_NameHAVING COUNT(FS.Streams_Key) > 1;
This concludes our discussion on Datameer — Simple transformations. Feel free to reach out to me if you have any questions.
How to check if the computer is connected to a domain using PowerShell?

To check if a computer is connected to any domain we can use multiple methods. In this article, we can use two methods. One using the System Information of the computer and the second using the DirectoryServices .Net Class.
First method using System Information and filter out a string called “Domain” which shows us if the computer is in the domain or the workgroup.
systeminfo | findstr "Domain"
If the computer is in the workgroup, It will show the workgroup name. For example,
In the second method, we will use the directory service .Net class method name GetComputerDomain(). If the server is not connected to the domain then this command will throw an error.
For the server connected to a domain,
[System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain()
Forest                  : labdomain.local
DomainControllers       : {ADDC.labdomain.local}
Children                : {}
DomainMode              :
Parent                  :
PdcRoleOwner            : ADDC.labdomain.local
RidRoleOwner            : ADDC.labdomain.local
InfrastructureRoleOwner : ADDC.labdomain.local
Name                    : labdomain.local
You can filter out the domain name using Name Property.
[System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain() | Select  Name
Name
----
labdomain.local
If the server is not connected to the domain then, it will throw an error saying the local computer is not joined to any domain as shown below.
How to insert a space between characters of all the elements of a given NumPy array? - GeeksforGeeks

29 Aug, 2020
In this article, we will discuss how to insert a space between the characters of all elements of a given array of string. Example:
Suppose we have an array of string as follows:
A = ["geeks", "for", "geeks"]

then when we insert a space between the characters
of all elements of the above array we get the 
following output.
A = ["g e e k s", "f o r", "g e e k s"]

To do this we will use np.char.join(). This method basically returns a string in which the individual characters are joined by separator character that is specified in the method. Here the separator character used is space. 
Syntax: np.char.join(sep, string) 
Parameters:sep: is any specified separator string: is any specified string. 
Example:
Python3
# importing numpy as npimport numpy as np    # creating array of stringx = np.array(["geeks", "for", "geeks"],             dtype=np.str)print("Printing the Original Array:")print(x)  # inserting space using np.char.join()r = np.char.join(" ", x)print("Printing the array after inserting space\between the elements")print(r)
Output:
Printing the Original Array:
['geeks' 'for' 'geeks']
Printing the array after inserting spacebetween the elements
['g e e k s' 'f o r' 'g e e k s']
Python numpy-String Operation
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()
C++ Strings | Practice | GeeksforGeeks

Given two strings  S1 and S2 . You have to concatenate both the strings and print the concatenated string.
Example 1:
Input:
S1 = "Geeksfor"
S2 = "Geeks"
Output: GeeksforGeeks
Explanation: Combined "Geeksfor" and "Geeks"
 
Example 2:
Input:
S1 = "Practice"
S2 = "Hard"
Output: PracticeHard
Explanation: Combined "Practice" and "Hard"
 
Your Task:  
You dont need to read input or print anything. Complete the function conCat() which accepts two strings S1 and S2 as input parameter and returns concatenated string.

Expected Time Complexity: O(|S1| + |S2|) .
Expected Auxiliary Space: O(|S1| + |S2|) .
where N is the length of a String

Constraints:
1 <= |S1| , |S2| <= 105
|S| denotes the length of the string S.
0
visionsameer395 days ago
IN PTYHON 
class Solution:
   def conCat(self,s1,s2):       return s1+s2
0
aravindmn75831 week ago
//c++ solution -→run time 0.03sec
string conCat(string s1 , string s2)
{
    // code here.
    string ans;
    ans = s1+s2;
    return ans;
}
0
0niharika22 months ago
return s1 + s2;
0
imabheek2 months ago
// JAVA one line
return s1.concat(s2);
0
nimbalkarbhagyesh69792 months ago
0.1sec
string conCat(string s1 , string s2){   return s1.append(s2);} 
0
ishivamthombre2 months ago
Java Solution :- (0.5 sec)
class Sol
{
   String conCat(String s1 , String s2)
   {
       return s1+s2;
   }
}
0
vishwajeetofficial20223 months ago
//JAVA SOLUTION
class Sol
{
   String conCat(String s1 , String s2)
  
   {
       //code here.
       String s3="";
         // s3=s1+s2; or
       s3=s1.concat(s2);
      return s3;
   }
  
}
+2
pankajkumarravi6 months ago
*************** One Line Logic **********
 
        return s1+s2; 
 
-2
rajmuskan0907 months ago
string conCat(string s1 , string s2)
{
    // code here.
    string s3;
    s3=s1+s2;
    return s3;
    
}

0
Gurucharan Rajput9 months ago
Gurucharan Rajput
very easy way to solve
       return s1+s2;
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.
Proving Soundness of Armstrong's Axioms - GeeksforGeeks

17 Sep, 2021
Prerequisite – Armstrong’s Axioms in Functional Dependency in DBMS Armstrong mentioned that rules 1 through 3 have completeness along with soundness. Armstrong axioms are sound as they do not generate any incorrect Functional Dependencies and it allows us to generate the F+ closure. 
The proof of Soundness – Set of functional dependencies that can be derived with logic from a given set of functional dependencies (Fclosure) and the set of functional dependencies that can be inferred from Armstrong’s Axioms (Farmstrong) are same. In terms of sets, if we want to show equality, then we mention that one is a proper subset of the other. Hence, we need to prove that, 
 
 Farmstrong  is a proper subset of Fclosure 
    for soundness.
This means that all things derived from F after applying Armstrong’s Axioms are correct functional dependencies and this property is called Soundness. 
 
Consideration for Soundness – has been derived from F using Armstrong’s Axioms after m number of steps. 
In each step we would apply the rules of reflexivity, augmentation and transitivity. (If we derive from Axioms which are only 3 in number, the repeated application of them would also give similar results.) 
Rule of Reflexivity – This rule states that if E is a proper subset of G, then G implies E (). This rule always results in correct Functional Dependencies because it is a trivial functional dependency. 
Rule of Augmentation – This rule states that for , if we add Z on both sides, then we would get , which would be a correct functional dependency. If ta and tb have the same corresponding values in G and Z (GZ), It would mean that they have same corresponding value for G, which would mean that they have same corresponding value for E, since G implies E, it would also mean that they correspond to E and Z (EZ). 
Rule of Transitivity – This rule states that if , then G determines Z () If ta and tb have the same corresponding values in G which would mean that they have same corresponding value for E, since G implies E holds, it would also mean that they correspond to E, since E implies Z holds. 
So, applying these 3 rules will always give rise to correct functional dependencies (even if we apply them m number of times). Hence proved. 
chhabradhanvi
DBMS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of Functional dependencies in DBMS
Introduction of Relational Algebra in DBMS
What is Temporary Table in SQL?
KDD Process in Data Mining
Two Phase Locking Protocol
Difference between Star Schema and Snowflake Schema
Difference between File System and DBMS
Nested Queries in SQL
Difference between OLAP and OLTP in DBMS
What is Cursor in SQL ?
C program to print name inside heart pattern using for loop.

Write a program to print heart shaped pattern with the name in centre using for loop.
The user has to enter the name that should be printed in centre along with the number of rows the stars has to be print.
Refer an algorithm given below to print the name in heart pattern by using for loop.
Step 1 − Declare variables.
Step 2 − Read a name at runtime that should be printed on centre.
Step 3 − Read number of rows.
Step 4 − Find the length of name.
Step 5 − Print upper part of the heart.
Step 6 − Print lower part of the heart.
Step 7 − Print the name on screen.
Following is the C program to print the name in heart pattern by using for loop −
 Live Demo
#include <stdio.h>
#include <string.h>
int main(){
   int i, j, n;
   char name[50];
   int len;
   printf("Enter your name: ");
   gets(name);
   printf("Enter no of rows: ");
   scanf("%d", &n);
   len = strlen(name);
   // Print upper part of the heart shape with stars
   for(i=n/2; i<=n; i+=2){
      for(j=1; j<n-i; j+=2){
         printf(" ");
      }
      for(j=1; j<=i; j++){
         printf("*");
      }
      for(j=1; j<=n-i; j++){
         printf(" ");
      }
      for(j=1; j<=i; j++){
         printf("*");
      }
      printf("\n");
   }
   // Prints lower triangular part with stars
   for(i=n; i>=1; i--){
      for(j=i; j<n; j++){
         printf(" ");
      }
      // Print the name on screen
      if(i == n){
         for(j=1; j<=(n * 2-len)/2; j++){
            printf("*");
         }
         printf("%s", name);
         for(j=1; j<(n*2-len)/2; j++){
            printf("*");
         }
      }else{
         for(j=1; j<=(i*2)-1; j++){
            printf("*");
         }
      }
      printf("\n");
   }
   return 0;
}
When the above program is executed, it produces the following output −
Enter your name: Tutorials POint
Enter no of rows: 10
      ***** *****
    ******* *******
  ********* *********
   **Tutorials POint*
   *****************
    ***************
     *************
      ***********
       *********
        *******
         *****
          ***
           *
aclocal command in Linux with Examples - GeeksforGeeks

15 May, 2019
aclocal command in Linux is used to automatically generate aclocal.m4 files from configure.in file. automake in Linux contain a lot of autoconf macros that can be used in the different packages. These macros must be defined in the aclocal.m4. If not, then it can’t be accessed by the autoconf.The aclocal command first scans for macro definitions in the .m4 files in its default directory (/usr/share/aclocal on some systems) and also in the file acinclude.m4 after which it scans for macros used in the configure.in file. It will generate an aclocal.m4 file that contains definitions of all the m4 macros required by autoconf.
Syntax:
aclocal [, OPTION/]... [, SRCDIR/]
Options:
–acdir=dir : This option is used to search macro files in directory dir instead of the default directory.
–help: Display the help message and then exits.
-I DIRECTORY: Add the directory DIR to the list of directories searched for the .m4 files.
–system-acdir=dir: Shows the directory holding third party system wide files.
–output=FILE: Cause the output to be put into specified FILE instead of aclocal.m4.
–diff: Runs the command diff on m4 files that might be changed.
–verbose: It prints the names of the files it examines.
–print-ac-dir: Prints the name of the directory to be searched for m4 files, then exit.
–force: Always updates the output file.
–dry-run: Pretends to update the files.
–version: Shows the version number and then exits.
-W or –warnings: Reports the warning’s falling in the category.The warning categories are:
The warning categories are:
linux-command
Linux-file-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
SED command in Linux | Set 2
mv command in Linux with examples
Docker - COPY Instruction
chown command in Linux with Examples
nohup Command in Linux with Examples
Thread functions in C/C++
Named Pipe or FIFO with example C program
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux
How to Install an APK on the Emulator in Android Studio? - GeeksforGeeks

06 Oct, 2021
In this article, we will know, how we can install APK in our Android Studio Emulator. There are several methods to do that but most of them are quite unreliable and confusing but in this article, we are going to do that with some very easy methods with some very easy steps.
Step 1: Opening Emulator
First of all, we need to open the Android Studio Emulator properly, so that we can see the app that we are going to install in it. Before going to the 2nd Step we will also need that APK file in advance that we will install. In this case, I am using a testapp.apk file that we are going to install.
Step 2: Navigate to the Path below
C:\Users\<UserName>\AppData\Local\Android\Sdk\platform-tools
We have to go to the path mentioned above and paste the APK file here, after that Shift+Right Click at the same window and open the PowerShell window.
Opening Powershell window
After opening Powershell type the following commands
.\adb.exe install testapp.apk
In the Powershell window type the following command and it will install the app in the emulator and that’s it your APK is installed in the Emulator.
This method is much simpler than 1st method. We just need the APK file to install it in the Emulator. First of all, we still have to open the Emulator and after that drag, your APK file and drop it in the emulator anywhere and that’s it it will simply install that app in the Emulator.
In conclusion, we have learned two methods to install an APK file in the Android Studio Emulator. So if we need to use any external third-party application in our Emulator then we can prefer the above methods to do that.
Android-Studio
how-to-install
Picked
Android
How To
Installation Guide
Android
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Resource Raw Folder in Android Studio
Flutter - Custom Bottom Navigation Bar
How to Read Data from SQLite Database in Android?
How to Post Data to API using Retrofit in Android?
Retrofit with Kotlin Coroutine in Android
How to Install PIP on Windows ?
How to Find the Wi-Fi Password Using CMD in Windows?
How to install Jupyter Notebook on Windows?
How to Align Text in HTML?
How to filter object array based on attributes?
How do I bind the enter key to a function in Tkinter?

Pressing a key and handling some operation with the key is an event that can be triggered through a button. We can bind the key event using the Binding method in a tkinter application.
Whenever the key will be triggered, it will call a handler that will raise the specific operation for the key event.
If we want to trigger the Enter key with the bind function, we will use the bind('<Key>', Handler) method. For Enter Key, we use bind('<Return>', Handler) function.
#Import the tkinter library
from tkinter import *

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

#Set the geometry
win.geometry("650x250")

def handler(e):
   label= Label(win, text= "You Pressed Enter")
   label.pack()

#Create a Label
Label(win, text= "Press Enter on the Keyboard", font= ('Helvetica bold', 14)).pack(pady=20)

#Bind the Enter Key to Call an event
win.bind('<Return>',handler)

win.mainloop()
It will display the following window −
Now, if we will press "Enter" on the keyboard, it will display “You Pressed Enter”.
CSS | polygon() Function

05 Apr, 2021
The polygon() function is an inbuilt function in CSS which is used with the filter property to create a polygon of images or text.Syntax:  
polygon( percentage | length);
Parameter: This function accepts two parameter percentage or length which is used to hold the value of polygon size. Return value: It makes the polygon shape image or text as user want.Example:  
html
<!DOCTYPE html><html> <head>    <title>        CSS | polygon() function    </title>     <style>        div {            float: left;            width: 250px;            height: 160px;            shape-outside: polygon(0 0, 100% 50%, 0 100%);        }                 img {            -webkit-clip-path: polygon(0 0, 100% 50%, 0 100%);            clip-path: polygon(0 0, 100% 50%, 0 100%);        }                 h1,        h4 {            text-align: center;        }                 h1 {            color: green;        }    </style></head> <body>    <h1>GeeksforGeeks</h1>    <h4>CSS | polygon() function</h4>    <div>        <img src="https://media.geeksforgeeks.org/wp-content/uploads/20190808143838/logsm.png"             alt="Longtail boat in Thailand">    </div>     <p>How many times were you frustrated while looking out      for a good collection of programming/algorithm/interview      questions? What did you expect and what did you get?      This portal has been created to provide well written,      well thought and well explained solutions for selected      questions. An IIT Roorkee alumnus and founder of      GeeksforGeeks. He loves to solve programming problems      in most efficient ways. Apart from GeeksforGeeks, he      has worked with DE Shaw and Co. as a software developer      and JIIT Noida as an assistant professor. It is a good      platform to learn programming. It is an educational      website. Prepare for the Recruitment drive of product      based companies like Microsoft, Amazon, Adobe etc with      a free online placement preparation course.</p> </body> </html>
Output:  
Supported browser: The browser supported by CSS | polygon() Function are listed below:  
Google Chrome
Microsoft Edge
Mozilla Firefox
Safari
Opera
 
arorakashish0911
CSS-Functions
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of CSS (Cascading Style Sheet)
Design a Tribute Page using HTML & CSS
How to set space between the flexbox ?
How to position a div at the bottom of its container using CSS?
How to Upload Image into Database and Display it using PHP ?
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Mahotas – Zernike Moments

19 Feb, 2022
In this article, we will see how we can get the Zernike moments of the given image in mahotas. Zernike polynomials are an orthogonal basis set (a set of functions for which the integral of the product of any pair of functions is zero). In image processing, computer vision, and related fields, an image moment is a certain particular weighted average of the image pixels’ intensities, or a function of such moments, usually chosen to have some attractive property or interpretation. Image moments are useful to describe objects after segmentation.For this tutorial, we will use the ‘Lena’ image, below is the command to load the Lena image  
mahotas.demos.load('lena')
Below is the Lena image  
 
In order to do this we will use mahotas.features.zernike_moments methodSyntax : mahotas.features.zernike_moments(img, radius)Argument : It takes image object and integer as argumentReturn : It returns 1-D array  
Note: Input image should be filtered or should be loaded as greyIn order to filter the image we will take the image object which is numpy.ndarray and filter it with the help of indexing, below is the command to do this 
image = image[:, :, 0]
Below is the implementation  
Python3
# importing required librariesimport mahotasimport mahotas.demosfrom pylab import gray, imshow, showimport numpy as npimport matplotlib.pyplot as plt   # loading imageimg = mahotas.demos.load('lena')   # filtering imageimg = img.max(2) print("Image")   # showing imageimshow(img)show() # radiusradius = 10 # computing zernike momentsvalue = mahotas.features.zernike_moments(img, radius)   # printing valueprint(value)
Output : 
Image
 
 
[0.31830989 0.01261485 0.00614926 0.00769591 0.0097145  0.01757332
 0.00617458 0.01008905 0.01415304 0.01099679 0.02894761 0.01838737
 0.0074247  0.01333135 0.01958184 0.00431827 0.00540781 0.01675913
 0.03511082 0.00699177 0.00357231 0.01593838 0.01621848 0.0240565
 0.0154929 ]
Another example  
Python3
# importing required librariesimport mahotasimport numpy as npfrom pylab import gray, imshow, showimport osimport matplotlib.pyplot as plt  # loading imageimg = mahotas.imread('dog_image.png')  # filtering imageimg = img[:, :, 0]   print("Image")   # showing imageimshow(img)show() # radiusradius = 10 # computing zernike momentsvalue = mahotas.features.zernike_moments(img, radius)   # printing valueprint(value)
Output : 
Image
 
 
[0.31830989 0.00985427 0.00714652 0.00171408 0.00442245 0.01796711
 0.00716781 0.00179965 0.0039829  0.0031081  0.02447476 0.0011686
 0.009291   0.00174885 0.00357579 0.00692029 0.0043969  0.03528869
 0.00264739 0.01381883 0.00750501 0.0036528  0.00867514 0.01298398
 0.0129556 ]
 
arorakashish0911
reenadevi98412200
Python-Mahotas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Convert integer to string in Python
Python OOPs Concepts
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
Output of C++ Program | Set 1

21 May, 2019
Predict the output of below C++ programs.
Question 1
// Assume that integers take 4 bytes.#include<iostream>  using namespace std;     class Test{  static int i;  int j;};  int Test::i;  int main(){    cout << sizeof(Test);    return 0;}
Output: 4 (size of integer)static data members do not contribute in size of an object. So ‘i’ is not considered in size of Test. Also, all functions (static and non-static both) do not contribute in size.
Question 2
#include<iostream>  using namespace std;class Base1 { public:     Base1()     { cout << " Base1's constructor called" << endl;  }};  class Base2 { public:     Base2()     { cout << "Base2's constructor called" << endl;  }};  class Derived: public Base1, public Base2 {   public:     Derived()     {  cout << "Derived's constructor called" << endl;  }};  int main(){   Derived d;   return 0;}
Output:Base1’s constructor calledBase2’s constructor calledDerived’s constructor called
In case of Multiple Inheritance, constructors of base classes are always called in derivation order from left to right and Destructors are called in reverse order.
Akanksha_Rai
CPP-Output
Program Output
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Lodash _.indexOf() Method

22 Jul, 2020
The lodash _.indexOf() method is used to get the index of first occurrence of the particular element in the array. If fromIndex is not present in the array negative one is given as the output and no error is displayed.
Syntax:
indexOf(array, value, fromIndex)
Note: If the value is not found in the array -1 is returned.
Parameters: This method accepts three parameters as mention above and describe below.
array: It is the array in which value is to be found.
value: It is the value to be looked in the array.
fromIndex: It is the index after which we have to look for the value.
Return Value: It returns the index of the value in the array. If the value is not found, the array returned -1.
Example 1:
Javascript
// Requiring the lodash libraryconst _= require("lodash");  // Original arraylet array = [1,2,3,4]  // Printing original array console.log("Array : ",array)  // Looking for value 3 from index 0 let index = _.indexOf(array,3,0)  // Printing the Index of the value console.log("Index : ",index)
Output:
Example 2: Looking for a value from particular index. 
Javascript
// Requiring the lodash libraryconst _ = require("lodash");  // Original arraylet array = [1,2,3,4]  // Printing original array console.log("Array : ",array)  // Looking for 3 from index 3 // it will return -1let index = _.indexOf(array,3,3)  // Print Index of the value console.log("Index : ",index)
Output:
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to catch SystemExit Exception in Python?

In python documentation, SystemExit is not a subclass of Exception class. BaseException class is the base class of SystemExit. So in given code, we replace the Exception with BaseException to make the code work
try:
raise SystemExit
except BaseException:
print "It works!"
It works!
The exception inherits from BaseException instead of StandardError or Exception so that it is not accidentally caught by code that catches Exception.
We would rather write the code this way
try:
raise SystemExit
except SystemExit:
print "It works!"
It works!
How to set a different look and feels to swing components in Java?

The Java Swing allows us to customize the GUI by changing the look and feel(L&F). The look defines the general appearance of components and the feel defines their behavior. L&Fs are subclasses of the LookAndFeel class and each L&F is identified by its fully qualified class name. By default, the L&F is set to the Swing L&F ( Metal L&F)
To set the L&F programmatically, we can call the method setLookAndFeel () of the UIManager class. The call to setLookAndFeel must be done before instantiating any Java Swing class, otherwise, the default Swing L&F will be loaded.
public static void setLookAndFeel(LookAndFeel newLookAndFeel) throws UnsupportedLookAndFeelException
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class LookAndFeelTest extends JFrame implements ActionListener {
   private JRadioButton windows, metal, motif, ;
   private ButtonGroup bg;
   public LookAndFeelTest() {
      setTitle("Look And Feels");
      windows = new JRadioButton("Windows");
      windows.addActionListener(this);
      metal = new JRadioButton("Metal");
      metal.addActionListener(this);
      motif = new JRadioButton("Motif");
      motif.addActionListener(this);
      bg = new ButtonGroup();
      bg.add(windows);
      bg.add(metal);
      bg.add(motif);
      setLayout(new FlowLayout());
      add(windows);
      add(metal);
      add(motif);
      setSize(400, 300);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setLocationRelativeTo(null);
      setVisible(true);
   }
   @Override
   public void actionPerformed(ActionEvent ae) {
      String LAF;
      if(ae.getSource() == windows)
         LAF = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
      else if(ae.getSource() == metal)
         LAF = "javax.swing.plaf.metal.MetalLookAndFeel";
      else
         LAF = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
      try {
         UIManager.setLookAndFeel(LAF);
         SwingUtilities.updateComponentTreeUI(this);
      } catch (Exception e) {
         System.out.println("Error setting the LAF..." + e);
      }
   }
   public static void main(String args[]) {
      new LookAndFeelTest();
   }
}
SQL - SELECT Query

The SQL SELECT statement is used to fetch the data from a database table which returns this data in the form of a result table. These result tables are called result-sets.
The basic syntax of the SELECT statement is as follows −
SELECT column1, column2, columnN FROM table_name;

Here, column1, column2... are the fields of a table whose values you want to fetch. If you want to fetch all the fields available in the field, then you can use the following syntax.
SELECT * FROM table_name;
Consider the CUSTOMERS table having the following records −
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
The following code is an example, which would fetch the ID, Name and Salary fields of the customers available in CUSTOMERS table.
SQL> SELECT ID, NAME, SALARY FROM CUSTOMERS;
This would produce the following result −
+----+----------+----------+
| ID | NAME     | SALARY   |
+----+----------+----------+
|  1 | Ramesh   |  2000.00 |
|  2 | Khilan   |  1500.00 |
|  3 | kaushik  |  2000.00 |
|  4 | Chaitali |  6500.00 |
|  5 | Hardik   |  8500.00 |
|  6 | Komal    |  4500.00 |
|  7 | Muffy    | 10000.00 |
+----+----------+----------+

If you want to fetch all the fields of the CUSTOMERS table, then you should use the following query.
SQL> SELECT * FROM CUSTOMERS;
This would produce the result as shown below.
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+


    42 Lectures 
     5 hours 

 Anadi Sharma

    14 Lectures 
     2 hours 

 Anadi Sharma

    44 Lectures 
     4.5 hours 

 Anadi Sharma

    94 Lectures 
     7 hours 

 Abhishek And Pukhraj

    80 Lectures 
     6.5 hours 

 Oracle Master Training | 150,000+ Students Worldwide

    31 Lectures 
     6 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page