code-rag-bench/online-tutorials huggingface dataset:
How to Download and Install Shotcut Video Editor on Windows?

15 May, 2022
Shotcut is an open-source and cross-platform video editing software. It is developed by MLT Multimedia Framework. It is easy to use especially for the beginner who wants to learn video editing because it is free to use, provides a simple interface, and can work with any format of video, audio, or photo media. It is written in C, C++ languages and is available for all operating systems like Linux, macOS, Windows, etc. It does not depend upon the system codecs and can also run as a portable app from an external drive. It also performs an integrity check of an audio/video file. In this article, we will learn how to install Shotcut in Windows.
Follow the below steps to install Shotcut on Windows:
Step 1: Visit the official website using the URL https://shotcut.org/ with the help of any web browser to download Shotcut for Windows.
Step 2: Click on the Click to Download button.
Step 3: Next web page open, now click on Windows Installer and the file automatically started downloading.
Step 4: Now find the executable file in the Downloads folder of your system and open it.
Step 5: It will prompt confirmation to make changes to your system. Click on Yes.
 
Step 6: Next step is the License Agreement, so click on the I Agree button.
Step 7: Next step is the installing location. Now choose the drive which you want to install the Shotcut and that will have sufficient memory space for installation. By default, it installs in C drive. It required approximately 289.1 MB of memory space. Click on the Next button.
Step 8: Next screen is of choosing installation options, all options are not marked you can mark according to your requirement. Like if you want your software on the Desktop screen then mark Create Desktop Shortcut (Icon) option, if you want to remove old program files then mark Remove Old Program Files and then click on the Install button.
Step 9: After the installation process will start and will a few minutes to complete the installation.
Step 10: Setup is completed, now click on the Close button.
Now the Shotcut is successfully installed and an icon is created on the desktop.
Run the software to create a new project.
So this is how we install Shotcut in the Windows system.
lastbitcoder
how-to-install
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2017 (Set 1) | Question 34

01 Oct, 2021
Consider the following context-free grammar over the alphabet ∑ = {a, b, c} with S as the start symbol:
S → abScT | abcT
T → bT | b

Which of the following represents the language generated by the above grammar?(A) {(ab)n(cb)n | n >= 1 }(B) {(abncbm1cbm2...cbmn | n, m1, m2, ....., mn >= 1 }(C) {(ab)n(cbm)n | n >= 1 }(D) {(ab)n(cbn)m | m, n >= 1 }Answer: (B)Explanation: Let’s generate a string from given grammar :
S → abScT→ ab abScT cT→ abab abcT cTcT→ abababc bT cTcT→ abababcb bT cTcT→ abababcbb bT cTcT→ abababcbbbb cTcT→ abababcbbbbc b cT→ abababcbbbbcbc bT→ abababcbbbbcbcbb
This string can rule out all wrong options. Now let’s try to analyse this string.
→ abababcbbbbcbcbb
→ {(abncbm1cbm2...cbmn | n, m1, m2, ....., mn >= 1 }
We can clearly rule out option (A), (C) and (D) with help of the string generated by given grammar.
Only option (B) is correct.
GATE PYQ's on Grammars with Praddyumn Shukla | GeeksforGeeks GATE - YouTubeGeeksforGeeks GATE Computer Science17.4K subscribersGATE PYQ's on Grammars with Praddyumn Shukla | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0047:05 / 1:02:45•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=zAzS1PzU0NQ" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2017 (Set 1)
GATE-GATE-CS-2017 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 2008 | Question 46
GATE | GATE CS 1996 | Question 63
GATE | Gate IT 2005 | Question 52
GATE | GATE CS 2012 | Question 18
GATE | GATE CS 2008 | Question 40
GATE | GATE-CS-2001 | Question 50
Convert CSV to Excel using Pandas in Python

22 Feb, 2022
Pandas can read, filter, and re-arrange small and large datasets and output them in a range of formats including Excel. In this article, we will be dealing with the conversion of .csv file into excel (.xlsx). Pandas provide the ExcelWriter class for writing data frame objects to excel sheets. Syntax:  
final = pd.ExcelWriter('GFG.xlsx')
Example:Sample CSV File: 
 
Python3
import pandas as pd  # Reading the csv filedf_new = pd.read_csv('Names.csv') # saving xlsx fileGFG = pd.ExcelWriter('Names.xlsx')df_new.to_excel(GFG, index=False) GFG.save()
Output: 
The read_* functions are used to read data to pandas, the to_* methods are used to store data. The to_excel() method stores the data as an excel file. In the example here, the sheet_name is named passengers instead of the default Sheet1. By setting index=False the row index labels are not saved in the spreadsheet.
Python3
import pandas as pd # The read_csv is reading the csv file into Dataframe df = pd.read_csv("./weather_data.csv") # then to_excel method converting the .csv file to .xlsx file. df.to_excel("weather.xlsx", sheet_name="Testing", index=False) # This will make a new "weather.xlsx" file in your working directory.# This code is contributed by Vidit Varshney
viditvarshney
Picked
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Shell Script To Count Number of Words, Characters, White Spaces, and Special Symbols

20 Apr, 2021
In this article, we are going to see how to count the number of words, characters, whitespace and special symbol in a text file/ input string. Given a text file and tour task is to count the number of words, characters, whitespace and special symbol. So there are many methods and tool that we can use to accomplish our task. For better understanding let’s take an example:
Example:
Input text: GeeksforGeeks are best!

Output :
Number of  Words = 3
Number of  Characters = 24
Number of  White Spaces =2
Number of  Special Symbols = 2

Explanation:
words are { "GeeksforGeeks", "are", "best!!"}
Characters include number of white spaces(Space),special symbols and letter.
White Spaces are just spaces {' ',' '}
And Special Symbol are {'!','!'}
Using wc command. wc command is used to know the number of lines, word count, byte and characters count etc.
Count the number of words using wc -w. Here, “-w” indicates that we are counting words.
Count the number of characters using wc -c. Here, “-c” indicates that we are counting each character including white spaces.
Count the number of white spaces in a string using the following syntax:
Syntax: expr length “$text” – length `echo “$text” | sed “s/ //g”`
Sed command is used to manipulate text, it stands for stream editor. Here, we are using sed to find the whites paces using sed “s/replace this with the whitespace//g”. In this syntax sed s refer as substitute and g as globalism and this syntax will search and replace every whitespace in entire text.
Count all the special characters using following regular expression.
Syntax: expr length “${text//[^\~!@#$&*()]/}”
Shell Script:
#! /bin/bash

echo "Enter a String"
# Taking input from user
read text

# Counting words
word=$(echo -n "$text" | wc -w)
# Counting characters
char=$(echo -n "$text" | wc -c)

# Counting Number of white spaces (Here,specificly " ")
# sed "s/ change this to whitespace//g"
space=$(expr length "$text" - length `echo "$text" | sed "s/ //g"`)

# Counting special characters
special=$(expr length "${text//[^\~!@#$&*()]/}")

# Output
echo "Number of Words = $word"
echo "Number of Characters = $char"
echo "Number of White Spaces = $space"
echo "Number of Special symbols = $special"
Output:
Output 
Picked
Shell Script
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Filter rows with only Alphabets from List of Lists

02 Dec, 2020
Given Matrix, write a Python program to extract rows which only contains alphabets in its strings.
Examples:
Input : test_list = [[“gfg”, “is”, “best”], [“Geeks4Geeks”, “good”], [“Gfg is good”], [“love”, “gfg”]] Output : [[‘gfg’, ‘is’, ‘best’], [‘love’, ‘gfg’]] Explanation : All strings with just alphabets are extracted. 
Input : test_list = [[“gfg”, “is”, “!best”], [“Geeks4Geeks”, “good”], [“Gfg is good”], [“love”, “gfg”]] Output : [[‘love’, ‘gfg’]] Explanation : All strings with just alphabets are extracted. 
Method #1: Using isalpha() + all() + list comprehension
In this, we check for all the alphabets using isalpha() and all() is used to ensure all the strings contain just the alphabets. The list comprehension is used to iterate through rows.
Python3
# Python3 code to demonstrate working of# Filter rows with only Alphabets# Using isalpha() + all() + list comprehension  # initializing listtest_list = [["gfg", "is", "best"], ["Geeks4Geeks", "good"],             ["Gfg is good"], ["love", "gfg"]]  # printing original listsprint("The original list is : " + str(test_list))  # all() checks for all strings to contain alphabetsres = [sub for sub in test_list if all(ele.isalpha() for ele in sub)]  # printing resultprint("Filtered Rows : " + str(res))
Output:
The original list is : [[‘gfg’, ‘is’, ‘best’], [‘Geeks4Geeks’, ‘good’], [‘Gfg is good’], [‘love’, ‘gfg’]]Filtered Rows : [[‘gfg’, ‘is’, ‘best’], [‘love’, ‘gfg’]]
Method #2 : Using filter() + lambda + join() + isalpha()
In this, we concatenate each string using join() and test if its all alphabets using isalpha(), and add if the verdict returns true.
Python3
# Python3 code to demonstrate working of# Filter rows with only Alphabets# Using filter() + lambda + join() + isalpha()  # initializing listtest_list = [["gfg", "is", "best"], ["Geeks4Geeks", "good"],             ["Gfg is good"], ["love", "gfg"]]  # printing original listsprint("The original list is : " + str(test_list))  # join() used to concatenate stringsres = list(filter(lambda sub: ''.join(    [ele for ele in sub]).isalpha(), test_list))  # printing resultprint("Filtered Rows : " + str(res))
Output:
The original list is : [[‘gfg’, ‘is’, ‘best’], [‘Geeks4Geeks’, ‘good’], [‘Gfg is good’], [‘love’, ‘gfg’]]Filtered Rows : [[‘gfg’, ‘is’, ‘best’], [‘love’, ‘gfg’]]
Python list-programs
Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How To Make Density Plot in Python with Altair?

17 May, 2021
Density plots are a variation of Histograms that are used to observe the distribution of a variable in data set over a continuous interval or a time period. The peaks of a Density Plot indicate where values are concentrated over an interval.
Compared to Histograms, Density Plots are better at determining the distribution shape because they’re not affected by the number of bins.
We can make a density plot in python using the libraries Pandas and Altair.
Altair-It is a statistical visualization library based on Vega and Vega-lite.
Pandas-It is an open-source data analysis and manipulation tool in Python.
Note: We will be using the ‘insurance.csv’ dataset which can be downloaded from Google Drive.
First, let’s import these libraries using-
Python3
import pandas as p  # loading pandas libraryimport altair as a  # loading altair library
Next, we load the data set on which we need to use the density plot.
Python3
data_set = 'insurance.csv'  # dataset named = p.read_csv(data_set)  # reading the datasaetd.head()  # printing the first 5 data entries
Output:
As you can see, there are seven columns in the dataset. We shall use “charges” to make a density plot. To do, so we must first transform our data into density. This is done by using the transform_density() function. The parameters are the variable of interest and a name to indicate the transformed variable which is written as “as_=[‘Charges’, ‘density’]”. Bringing it together-
Python3
# loading a single column into# the data frame objectd = d[["charges"]] a.Chart(d).transform_density('charges', as_=['CHARGES', 'DENSITY'],                             ).mark_area(color='green').encode(    x="CHARGES:Q",    y='DENSITY:Q', )
 
 
Output:
 
Output
 
Complete Script: Here is the code with all the steps at one place-
 
Python3
import pandas as p  # loading pandas libraryimport altair as a  # loading altair library # download dataset from https://drive.google.com/drive/folders/1Dddv1l9hpEPVWh_uuK9Iv1A1xUNy55v7?usp=sharing# OR replace name with your own dataset.data_set = 'insurance.csv'd = p.read_csv(data_set)d = d[["charges"]] a.Chart(d).transform_density('charges', as_=['CHARGES', 'DENSITY'],                             ).mark_area(color='green').encode(    x="CHARGES:Q",    y='DENSITY:Q',)
Output:
Output
sweetyty
Python-Altair
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JavaScript String startsWith() Method

06 Oct, 2021
Below is the example of the String startsWith() Method.  
Example:  
JavaScript
<script>function func() {    var str = 'Geeks for Geeks';    var value = str.startsWith('Gee');    document.write(value);}func();</script>
Output:  
true
The str.startsWith() method is used to check whether the given string starts with the characters of the specified string or not. Syntax:  
str.startsWith( searchString , position )
Parameters: This method accepts two parameters as mentioned above and described below:  
searchString: It is required parameter. It stores the string which needs to search.
start: It determines the position in the given string from where the searchString is to be searched. The default value is zero.
Return value This method returns the Boolean value true if the searchString is found else returns false.Examples for the above method are provided below:Example 1:  
var str = 'It is a great day.';
var value = str.startsWith('It'); 
print(value);
Output:  
true
In the above example, the method startsWith() checks whether the string str starts with It or not. Since the string starts with It therefore it returns true.Example 2:  
var str = 'It is a great day.';
var value = str.startsWith('great');
print(value);
Output:  
false
In this example, the method startsWith() checks whether the string str starts with great or not. Since great appears in the middle and not in the beginning of the string therefore it returns false.Example 3:  
var str = 'It is a great day.'
var value = str.startsWith('great',8);
print(value);
Output:  
true
In this example the method startsWith() checks whether the string str starts with great or not at the specified index 8. Since great appears at the given index in the string therefore it returns true.Below programs illustrate the startsWith() method in JavaScript:Program 1:  
JavaScript
<script>// JavaScript to illustrate startsWith() method function func() {          // Original string    var str = 'It is a great day.';         // Checking the condition    var value = str.startsWith('It');    document.write(value);}func();</script>
Output:  
true
Program 2:  
JavaScript
<script> // JavaScript to illustrate// startsWith() methodfunction func() {         // Original string    var str = 'It is a great day.';    var value = str.startsWith('great');    document.write(value);}func();</script>
Output:  
false
Program 3:  
JavaScript
<script> // JavaScript to illustrate// startsWith() methodfunction func() {          // Original string    var str = 'It is a great day.';    var value = str.startsWith('great', 8);    document.write(value);} // Function callfunc(); </script>
Output:  
true
Supported Browser:
Chrome 41 and above
Edge 12 and above
Opera 28 and above
Firefox 17 and above
Safari 9 and above
ysachin2314
JavaScript-Methods
javascript-string
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Samsung Software – Competency Test (Samsung R&D Bangalore) Experience > 1 yrs

13 Feb, 2020
Round 1:   If your body Temperature is above 36 degree, You have to go back .(I don’t know why?)
 
Round 2:  we have to complete One Question within 4 hrs. There were 50 test cases, 5 test cases are visible and other 45 are in backend.
Yor are not allowed to use any library functions such as Array List, Stack, Queue.....
c/c++ java -allowed language, c# python and  others –not allowed
 
In between they will provide Orio, juice coffee water ....(enjoy)
Question :(It was story based ...so actually I am  not that brainy to write whole story...so some glimpse)
It was midnight, Robert joy was travelling in a ship, suddenly traveller got the distinct impression that the ship was swerving. Suddenly, however, the ship shook with a strange back-and-forth movement and began to wallow, it was typhoon ... So he decided to jump off the ship . Somehow he manages to take Lifeboat and while deboard, he puts some 3D block along with him . when he wake up, he found himself in Island, surrounded by light blue color ....
he get down from the lifeboat and tried to send a signal to Rescue team. But he didnt make it ...
So he decided to make height so that he can easily send the signal .. So whatever he kept the 3D blocks in lifeboat  along with him, He started keeping one above another.
But the robert joy was very week in Mathematics and programmings, Imagine You were there and asking for help, to find the maximum Height by creating stack of 3D boxes, so that he can easily send the signal to rescue team .
But condition is there :
— you can only stack a box on top of another box if the dimensions of the 2-D base of the lower box are each strictly larger than those of the 2-D base of the higher box
|__________|
|________|                Not possible here (consider 3D box) They will provide you proper image .
 
— multiple Instances of same block can be used so that block can be rotated to use any side as its base.
 
let say N is the Number Of block he has ...2<=N <=20;
Test cases: 1<=T<= 1000;
Input –  T : No of Test cases
N  : no of block
l, w, h   :      Lenght, width and height of each block .
Eg.
2
27  31 24
76   33  3
Ans : 76
3
9 9 9
1 1 1
435 345 567
Ansc : 577
I solved using DP but didn’t able to pass  most of the hidden  test cases, (So golden words came to me  ” you may leave for the day “.)
Note : If You are really ready then go for this test, because They will provide you only 3 attempts for entire life. so never miss a chance, (I missed one) and if you are thinking you ll use another email and phone, u ll get blocked ..so be careful . This Is R&D.
 
Marketing
Samsung
Interview Experiences
Samsung
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
wcslen() function in C++ with Examples

03 Oct, 2018
The wcslen() function is defined in cwchar.h header file. The function wcslen() function returns the length of the given wide string.
Syntax:
size_t wcslen(const wchar_t* str);
Parameter: This method takes a single parameter str which represents the pointer to the wide string whose length is to be calculated.
Return Value: This function returns the length of wide string.
Below programs illustrate the above function:-
Example 1:-
// c++ program to demonstrate// example of wcslen() function.  #include <bits/stdc++.h>using namespace std;  int main(){      // Get the string to be used    wchar_t str[] = L"geeks";      // Get the length of the string using wcslen()    wcout << L"The length of '" << str          << L"' is =" << wcslen(str) << endl;      return 0;}
The length of 'geeks' is =5

Example 2:-
// c++ program to demonstrate// example of wcslen() function.  #include <bits/stdc++.h>using namespace std;  int main(){      // Get the string to be used    wchar_t str[] = L"A computer science portal for geeks";      // Get the length of the string using wcslen()    wcout << L"The length of '" << str          << L"' is =" << wcslen(str) << endl;      return 0;}
The length of 'A computer science portal for geeks' is =35

=
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Can we insert values without mentioning the column name in MySQL?

Yes, we can insert values without mentioning the column name using the following syntax −
insert into yourTableName values(yourValue1,yourValue2,yourValue3,.....N);
Let us first create a table. Here, we have set Id as NOT NULL −
mysql> create table DemoTable862(
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   FirstName varchar(100) ,
   Age int
);
Query OK, 0 rows affected (0.68 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable862 values(NULL,'Chris',23);
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable862 values(NULL,'Robert',21);
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable862 values(NULL,'Mike',24);
Query OK, 1 row affected (0.09 sec)
mysql> insert into DemoTable862 values(NULL,'Sam',25);
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable862 values(NULL,'Bob',26);
Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable862;
This will produce the following output. Above, we have set NULL while inserting the values. Since we have set Id as NOT NULL, therefore those NULL values won’t work for Id column and the auto_increment will automatically add values for Id −
+----+-----------+------+
| Id | FirstName | Age  |
+----+-----------+------+
| 1  | Chris     |   23 |
| 2  | Robert    |   21 |
| 3  | Mike      |   24 |
| 4  | Sam       |   25 |
| 5  | Bob       |   26 |
+----+-----------+------+
5 rows in set (0.00 sec)
ArrayDeque removeFirst() Method in Java - GeeksforGeeks

10 Dec, 2018
The Java.util.ArrayDeque.removeFirst() method is used to remove the first element of the Deque.
Syntax:
Array_Deque.removeFirst()
Parameters: The method does not take any parameters.
Return Value: This method returns the first element of the Deque after removing it.
Exceptions: The method throws NoSuchElementException is thrown if the deque is empty.
Below programs illustrate the Java.util.ArrayDeque.removeFirst() method:
Program 1:
// Java code to illustrate removeFirst()import java.util.*;  public class ArrayDequeDemo {    public static void main(String args[])    {        // Creating an empty ArrayDeque        Deque<String> de_que = new ArrayDeque<String>();          // Use add() method to add elements into the Deque        de_que.add("Welcome");        de_que.add("To");        de_que.add("Geeks");        de_que.add("For");        de_que.add("Geeks");          // Displaying the ArrayDeque        System.out.println("Initial ArrayDeque: " + de_que);          // Removing elements using removeFirst() method        de_que.removeFirst();        de_que.removeFirst();        de_que.removeFirst();          // Displaying the ArrayDeque after removal        System.out.println("ArrayDeque after removing "                           + "elements: " + de_que);    }}
Initial ArrayDeque: [Welcome, To, Geeks, For, Geeks]
ArrayDeque after removing elements: [For, Geeks]

Program 2:
// Java code to illustrate removeFirst()import java.util.*;  public class ArrayDequeDemo {    public static void main(String args[])    {        // Creating an empty ArrayDeque        Deque<Integer> de_que = new ArrayDeque<Integer>();          // Use add() method to add elements into the Deque        de_que.add(10);        de_que.add(15);        de_que.add(30);        de_que.add(20);        de_que.add(5);          // Displaying the ArrayDeque        System.out.println("Initial ArrayDeque: " + de_que);          // Removing elements using removeFirst() method        de_que.removeFirst();        de_que.removeFirst();          // Displaying the ArrayDeque after removal        System.out.println("ArrayDeque after removing "                           + "elements: " + de_que);    }}
Initial ArrayDeque: [10, 15, 30, 20, 5]
ArrayDeque after removing elements: [30, 20, 5]

Java - util package
Java-ArrayDeque
Java-Collections
Java-Functions
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Reverse a string in Java
HashMap in Java with Examples
Interfaces in Java
Object Oriented Programming (OOPs) Concept in Java
ArrayList in Java
Arrays.sort() in Java with examples
How to iterate any Map in Java
Where do we use $.extend() method in jQuery?

The jQuery.extend() method is used to merge contents of two or more objects together. The object is merged into the first object. 
You can try to run the following code to learn how to use extend() method −
Live Demo
<!DOCTYPE html>
<html>

<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
  $("#button1").click(function() {
    var obj1 = {
      maths: 60,
      history: {pages: 150,price: 400,lessons: 30},
      science: 120
    };
    var obj2 = {
      history: { price: 150, lessons: 24 },
      economics: 250
    };
    $.extend(true, obj1, obj2);
    $("#demo").append(JSON.stringify(obj1));
   });
});
</script>
</head>
<body>
   <button id="button1">Result</button>
   <div id="demo"></div>
</body>
</html>
C# | How to change BufferHeight of the Console - GeeksforGeeks

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

The slice operator in Python takes two operands. First operand is the beginning of slice. The index is counted from left by default. A negative operand starts counting from end. Second operand is the index of last character in slice. If omitted, slice goes upto end.
We want last four characters. Hence we count beginning of position from end by -4 and if we omit second operand, it will go to end.
>>> string = "Thanks. I am fine"
>>> string[-4:]
'fine'
Concatenate 2 strings in ABAP without using CONCATENATE function

In ABAP you can use && sign to concatenate variables as below
hello TYPE string,
world TYPE string,
helloworld TYPE string.
hello = 'hello'.
world = 'world'.
helloworld = hello && world.
If you want to concatenate strings directly, you can use
helloworld = 'hello' && 'world'.
If you want to keep space in between, you would require ` symbol as below
helloworld = hello && ` and ` && world
Lodash _.forOwn() Method - GeeksforGeeks

14 Sep, 2020
The Lodash _.forOwn() Method Iterates over the own keys of the given object and invoke iteratee for each property. The iteratee function is invoked with three arguments: (value, key, object). Iteratee function may exit iteration early by explicitly returning false.
Syntax:
_.forOwn( object, iteratee_function)

Parameters: This method accepts two parameters as mentioned above and described below:
object: This is the object to find in.
iteratee_function: the function that is invoked per iteration.
Return Value: This method returns an object.
Example 1:
// Defining Lodash variable const _ = require('lodash');   var users = {  'a':  1,  'b':  2,  'c':  3};   _.forOwn(users, function(value, key) {  console.log(key, '=', value);});
Output:
a = 1
b = 2
c = 3

Example 2:
// Defining Lodash variable const _ = require('lodash');   var users = {  'a':  1,  'b':  2,  'c':  3};   _.forOwn(users, function(value, key) {    if(value > 2) {        console.log(key, value);    }});
Output:
c 3

Note: This will not work in normal JavaScript because it requires the lodash library to be installed and can be installed using the following command:
npm install lodash
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
How to detect browser or tab closing in JavaScript ?
How to get character array from string in JavaScript?
How to filter object array based on attributes?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
How to move the x-axis to top in a JavaFX line chart?

Inline chart, the data values have represented a series of points connected by a line. In JavaFX, you can create a line chart by instantiating the javafx.scene.chart.LineChart class.
By default,
A JavaFX Line chart contains symbols pointing out the values in the series
along the x-axis. Typically, these are small circles.
A JavaFX Line chart contains symbols pointing out the values in the series
along the x-axis. Typically, these are small circles.
The X-Axis on the bottom in the plot.
The X-Axis on the bottom in the plot.
Y-Axis on the left.
Y-Axis on the left.
The Axis class (superclass of all axes) has a property named side, this specifies the side of the plot at which you need to have the current axis (left, right, top-bottom). You can set the value to this property using the setSide() method. This method accepts one of the following values as a parameter −
Side.BOTTOM
Side.BOTTOM
Side.TOP
Side.TOP
Side.LEFT
Side.LEFT
Side.RIGHT
Side.RIGHT
To move the X-Axis to top, invoke the setSide() method on the object of the XAxis of your plot by passing the value Side.TOP as a parameter.
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Side;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.scene.layout.StackPane;
public class LineChartAxisShift extends Application {
   public void start(Stage stage) {
      //Defining the x an y axes
      CategoryAxis xAxis = new CategoryAxis();
      NumberAxis yAxis = new NumberAxis();
      //Setting labels for the axes
      xAxis.setLabel("Months");
      yAxis.setLabel("Rainfall (mm)");
      //Creating a line chart
      LineChart linechart = new LineChart(xAxis, yAxis);
      //Preparing the data points for the line1
      XYChart.Series series = new XYChart.Series();
      series.getData().add(new XYChart.Data("Jul", 169.9));
      series.getData().add(new XYChart.Data("Aug", 178.7));
      series.getData().add(new XYChart.Data("Sep", 158.3));
      series.getData().add(new XYChart.Data("Oct", 97.2));
      series.getData().add(new XYChart.Data("Nov", 22.4));
      series.getData().add(new XYChart.Data("Dec", 5.9));
      //Setting the name to the line (series)
      series.setName("Rainfall In Hyderabad");
      //Setting the data to Line chart
      linechart.getData().add(series);
      //Shifting the X-axis
      xAxis.setSide(Side.TOP);
      //Creating a stack pane to hold the chart
      StackPane pane = new StackPane(linechart);
      pane.setPadding(new Insets(15, 15, 15, 15));
      pane.setStyle("-fx-background-color: BEIGE");
      //Setting the Scene
      Scene scene = new Scene(pane, 595, 350);
      stage.setTitle("Line Chart");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
Python | Counting sign change in list containing Positive and Negative Integers - GeeksforGeeks

21 Jun, 2019
Given a list containing Positive and Negative integers, We have to find number of times the sign(Positive or Negative) changes in the list.
Input: [-1, 2, 3, -4, 5, -6, 7, 8, -9, 10, -11, 12] 
Output:9
Explanation : 
Sign change from -1 to 2, ans = 1
Sign change from 3 to -4, ans = 2
Sign change from -4 to 5, ans = 3
Sign change from 5 to -6, ans = 4
Sign change from -6 to 7, ans = 5
Sign change from 8 to -9, ans = 6
Sign change from -9 to 10, ans = 7
Sign change from 10 to -11 ans = 8
Sign change from -11 to 12, ans = 9

Input: [-1, 2, 3, -4, 5, -11, 12]  
Output:5
Explanation :
Sign change from -1 to 2, ans = 1
Sign change from 3 to -4, ans = 2
Sign change from -4 to 5, ans = 3
Sign change from 5 to -11, ans = 4
Sign change from -11 to 12, ans = 5


Let’s discuss certain ways in which this task is performed.
Method #1: Using IterationUsing Iteration to find number of time sign changes in the list.
# Python Code to find number of # time sign changes in the list.  # Input list InitializationInput = [-1, 2, 3, -4, 5, -6, 7, 8, -9, 10, -11, 12]   # Variable Initializationprev = Input[0]ans = 0  # Using Iterationfor elem in Input:    if elem == 0:        sign = -1    else:        sign = elem / abs(elem)      if sign == -prev:        ans = ans + 1        prev = sign  # Printing answerprint(ans)
Output :
9
Method #2: Using Itertools and groupbyThis is yet another way to perform this particular task using itertools.
# Python Code to find number of # time sign changes in the list.  # Input list InitializationInput = [-1, 2, 3, -4, 5, -6, 7, 8, -9, 10, -11, 12]   # Importingimport itertools  # Using groupbyOutput = len(list(itertools.groupby(Input, lambda Input: Input > 0)))  Output = Output -1  # Printing outputprint(Output)
Output :
9
Method #3: Using ZipThe most concise and readable way to find number of time sign changes in the list is using zip.
# Python Code to find number of # time sign changes in the list.  # Using zip to checkdef check(Input):    Input = [-1 if not x else x for x in Input]    # zip with leading 1, so that opening negative value is     # treated as sign change    return sum((x ^ y)<0 for x, y in zip([1]+Input, Input))  # Input list InitializationInput = [-1, 2, 3, -4, 5, -6, 7, 8, -9, 10, -11, 12] Output = check(Input)  Output = Output -1  # Printing outputprint(Output)
Output :
9
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Python OOPs Concepts
Python | Get unique values from a list
Check if element exists in list in Python
Python Classes and Objects
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Python | Pandas dataframe.groupby()
Create a directory in Python
How to set text direction in HTML?

To set text direction in HTML, use the style attribute. The style attribute specifies an inline style for an element. The style attribute is used with the CSS property direction to set direction. Just keep in mind, the usage of style attribute overrides any style set globally. It will override any style set in the HTML <style> tag or external style sheet.
You can use the following property values to set direction −
 
You can try to run the following code to set text direction in HTML
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML Text Direction</title>
</head>
<body>
   <p style = "direction: rtl;">
      This text will get displayed from right to left
   </p>
   <p>This is normal text.</p>
</body>
</html>
Converting days into years months and weeks - JavaScript

We are required to write a JavaScript function that takes in a number (representing the number of days) and returns an object with three properties, namely −
weeks, months, years, days
And the properties should have proper values of these four properties that can be made from the number of days. We should not consider leap years here and consider all years to have 365 days.
For example −
If the input is 738, then the output should be −
const output = {
   years: 2,
   months: 0,
   weeks: 1,
   days: 1
}
Let’s write the code for this function −
const days = 738;
const calculateTimimg = d => {
   let months = 0, years = 0, days = 0, weeks = 0;
   while(d){
      if(d >= 365){
         years++;
         d -= 365;
      }else if(d >= 30){
         months++;
         d -= 30;
      }else if(d >= 7){
         weeks++;
         d -= 7;
      }else{
         days++;
         d--;
      }
   };
   return {
      years, months, weeks, days
   };
};
console.log(calculateTimimg(days));
The output in the console: −
{ years: 2, months: 0, weeks: 1, days: 1 }
Python Program to Determine How Many Times a Given Letter Occurs in a String Recursively

When it is required to check the number of times a given letter occurs in a string using recursion, a method can be defined, and an ‘if’ condition can be used.
The recursion computes output of small bits of the bigger problem, and combines these bits to give the solution to the bigger problem.
Below is a demonstration for the same −
 Live Demo
def check_frequency(my_str,my_ch):
   if not my_str:
      return 0
   elif my_str[0]==my_ch:
      return 1+check_frequency(my_str[1:],my_ch)
   else:
      return check_frequency(my_str[1:],my_ch)
my_string = input("Enter the string :")
my_char = input("Enter the character that needs to be checked :")
print("The frequency of " + str(my_char) + " is :")
print(check_frequency(my_string,my_char))
Enter the string :jaanea
Enter the character that needs to be checked :a
The frequency of a is :
3
A method named ‘check_frequency’ is defined that takes a string and a character as parameters.
It checks to see if the characters in a string match the character passed to the method.
If they do, it is returned.
Else the method is called recursively on all characters of the string.
The string and the character are taken as user inputs.
The method is called by passing these values as parameters.
The output is dislayed on the console.
Algorithms | Analysis of Algorithms | Question 2 - GeeksforGeeks

16 May, 2019
What is the time complexity of fun()?
int fun(int n){  int count = 0;  for (int i = 0; i < n; i++)     for (int j = i; j > 0; j--)        count = count + 1;  return count;} 
(A) Theta (n)(B) Theta (n^2)(C) Theta (n*Logn)(D) Theta (nLognLogn)Answer: (B)Explanation: The time complexity can be calculated by counting number of times the expression “count = count + 1;” is executed. The expression is executed 0 + 1 + 2 + 3 + 4 + .... + (n-1) times.
Time complexity = Theta(0 + 1 + 2 + 3 + .. + n-1) = Theta (n*(n-1)/2) = Theta(n2)Quiz of this Question
Algorithms-Analysis of Algorithms
Analysis of Algorithms
Algorithms Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Algorithms | Dynamic Programming | Question 2
Algorithms | Dynamic Programming | Question 3
Algorithms | Analysis of Algorithms | Question 17
Algorithms | Greedy Algorithms | Question 1
Algorithms | Recursion | Question 9
Algorithms Quiz | Dynamic Programming | Question 8
Algorithms | Divide and Conquer | Question 6
Algorithms | Graph Traversals | Question 12
Algorithms | Sorting | Question 23
Algorithms | Sorting | Question 5
PHP Variable functions

If name of a variable has parentheses (with or without parameters in it) in front of it, PHP parser tries to find a function whose name corresponds to value of the variable and executes it. Such a function is called variable function. This feature is useful in implementing callbacks, function tables etc.
Variable functions can not be built eith language constructs such as include, require, echo etc. One can find a workaround though, using function wrappers.
In following example, value of a variable matches with function of name. The function is thus called by putting parentheses in front of variable
 Live Demo
<?php
function hello(){
   echo "Hello World";
}
$var="Hello";
$var();
?>
This will produce following result. −
Hello World
Here is another example of variable function with arguments
 Live Demo
<?php
function add($x, $y){
   echo $x+$y;
}
$var="add";
$var(10,20);
?>
This will produce following result. −
30
In following example, name of function to called is input by user
<?php
function add($x, $y){
   echo $x+$y;
}
function sub($x, $y){
   echo $x-$y;
}
$var=readline("enter name of function: ");
$var(10,20);
?>
This will produce following result. −
enter name of function: add
30
Concept of variable function can be extended to method in a class
<?php
class myclass{
   function welcome($name){
      echo "Welcome $name";
   }
}
$obj=new myclass();
$f="welcome";
$obj->$f("Amar");
?>
This will produce following result. −
Welcome Amar
A static method can be also called by variable method technique
 Live Demo
<?php
class myclass{
   static function welcome($name){
      echo "Welcome $name";
   }
}
$f="welcome";
myclass::$f("Amar");
?>
This will now throw exception as follows −
Welcome Amar
mysql_fetch_array vs mysql_fetch_assoc vs mysql_fetch_object?

These mysql_* functions are deprecated and other functions are available that gives better security and functionality.
Note: As an alternative, use either _assoc or _row though.
The function returns an associative array of strings that corresponds to the fetched row, or FALSE if there are no more rows. The associativity array tells us about the key value pair, whereas the key tells about any column name and the value tells about the row value.
Here we can map the column name as key and value as row. For example.
Key is ID and value is corresponding name.

This function name suggests that it returns an array. It fetches a result row as an associative array, a numeric array, or both. It has both numeric values as well as string values for a key.
This function returns row as an object and does not return an array.
Batch Script - LABEL

This batch command adds, sets or removes a disk label.
Label

@echo off 
label

The above command will prompt the user to enter a new label for the current drive.
 Print
 Add Notes
 Bookmark this page
A shorthand array notation in C for repeated values - GeeksforGeeks

18 Sep, 2017
In C, when there are many repeated values, we can use a shorthand array notation to define array. Below program demonstrates same.
// C program to demonstrate working of shorthand// array rotation.#include <stdio.h>  int main(){    // This line is same as    // int array[10] = {1, 1, 1, 1, 0, 0, 2, 2, 2, 2};    int array[10] = {[0 ... 3]1, [6 ... 9]2};      for (int i = 0; i < 10; i++)        printf("%d ", array[i]);    return 0;}
Output:
1 1 1 1 0 0 2 2 2 2 

Note that middle gap of 2 is automatically filled with 0.
This article is contributed by Kaushik Annangi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
c-array
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Command line arguments in C/C++
Core Dump (Segmentation fault) in C/C++
rand() and srand() in C/C++
fork() in C
Left Shift and Right Shift Operators in C/C++
Different methods to reverse a string in C/C++
TCP Server-Client implementation in C
Exception Handling in C++
Function Pointer in C
Structures in C
Tryit Editor v3.7

Tryit: HTML form element
Jupyter Notebook to PDF in a few lines | by Cornellius Yudha Wijaya | Towards Data Science

If you enjoy my content and want to get more in-depth knowledge regarding data or just daily life as a Data Scientist, please consider subscribing to my newsletter here.
While working on our Jupyter Notebook, sometimes we want to share our processed dataset complete with the created plot and the markdown explanation we already created in a readable form. There is an easy way to turn our Jupyer Notebooks into PDF files. Just with a simple setup, you can access your notebook as a PDF.
For example, I would use the notebook I provide in my article here to convert to the PDF form. Below is my Jupyter Notebook.
And below is the notebook in the PDF form.
As you can see, it shows all the codes and your explanation just like that. How fancy is it?
Now let me show you how to do it.
The first thing we need to do is to install the necessary package. Here we would use the package called notebook-as-pdf to help us convert Jupyter Notebook as PDF file. You need to run the following code in your command prompt.
pip install -U notebook-as-pdf
We also need an additional setup for Chromium. It is used to perform the HTML to PDF conversion. Just run the following code in your code prompt.
pyppeteer-install
Just like that, we have already finished our preparation. Now, let’s open the notebook you intend to convert into the PDF. In your notebook, click the file menu bar then select Download as then select the PDF via HTML to transform the notebook.
Just like that, you already have your notebook as a PDF file. If you prefer to use command prompt to convert the notebook, you could do it with the following code.
jupyter-nbconvert --to PDFviaHTML example.ipynb
The result would be called example.pdf as our Jupyter Notebook is called example.ipynb.
Here I showed you a trick to convert your Jupyter Notebook into a PDF file. It might be simple but will prove useful in the long run.
If you want to read more about the package, you can visit the website here.
Visit me on my LinkedIn or Twitter
If you are not subscribed as a Medium Member, please consider subscribing through my referral.