Download Google Images Using Python

Pradeep Elance
Updated on 08-Aug-2019 06:41:47

1K+ Views

Google offers many python packages which minimize the effort to write python code to get data from google services. One such package is google images download. It takes in the key words as parameters and locates the images with those keywords.ExampleIn the below example we limit the number of images to 5 and also allow the program to print the urls from where the files were generated.from google_images_download import google_images_download #instantiate the class response = google_images_download.googleimagesdownload() arguments = {"keywords":"lilly, hills", "limit":5, "print_urls":True} paths = response.download(arguments) #print complete paths to the downloaded images print(paths)OutputRunning the above code gives us the following ... Read More

Clear Screen in Python

Pradeep Elance
Updated on 08-Aug-2019 06:38:47

6K+ Views

In Python sometimes we have link the output and we want to clear the screen in the cell prompt we can clear the screen by pressing Control + l . But there are situations when we need to clear the screen programmatically depending on the amount of output from the program and how we want to format the output. In such case we need to put some commands in the python script which will clear the screen as and when needed by the program.We need the system() from the OS module of python to clear up the screen. For different ... Read More

Frozenset in Python

Pradeep Elance
Updated on 08-Aug-2019 06:31:31

383 Views

This function helps in converting a mutable list to an immutable one. This is needed when we have declared a list whose items are changeable but after certain steps we want to stop allowing the elements in it to change. In such scenario, we apply the frozenset() function as shown below.SyntaxSyntax: frozenset(iterable_object_name)In the below example we take a list, change its element and print it. Then in the next step we apply the frozenset function, and try changing the element again. In the second step we get the error showing that the list can not be modified anymore.Example# Before applying ... Read More

Boolean Array Puzzle in C

sudhir sharma
Updated on 08-Aug-2019 06:24:27

262 Views

This an array based puzzle that need you to change all the numbers of an array the contains two elements to 0. One element of the array is 0 and other may or may not be 0.To solve this puzzle the program needs to find the non-zero element and change in to 0.Their are the following constraints that are needed to solve the boolean array puzzle −Allowed operation is complement, other operations are not allowed.Loops and conditional statements are not allowed.Direct assignment is also not allowed.PROGRAM TO SOLVE BOOLEAN ARRAY PUZZLE#include using namespace std; void makeZero(int a[2]) {    a[ ... Read More

Abundant Number in C

sudhir sharma
Updated on 07-Aug-2019 14:44:39

3K+ Views

An abundant Number (also known as excessive number) is a number in the number theory which itself is smaller than the sum of all its proper divisors. For example, 12 is an abundant Number : divisors 1, 2, 3, 4, 6 , sum =16 >12.The difference between the sum of divisors and the number is called abundance. For above example abundance = 4 => 16 - 12 .To check for abundant number we will find all the factors of the number and add them up. This sum compared with the number show that if the number is abundant or not.PROGRAM ... Read More

Abs Function for Complex Number in C++

sudhir sharma
Updated on 07-Aug-2019 14:41:04

478 Views

The abs function in C++ is used to find the absolute value of a complex number. The absolute value of a complex number (also known as modulus) is the distance of that number from the origin in the complex plane. This can be found using the formula −For complex number a+bi:mod|a+bi| = √(a2+b2)The abs() function returns the result of the above calculation in C++. It is defined in the complex library that is needed to be included.PROGRAM TO SHOW USE OF abs() FUNCTION FOR COMPLEX NUMBERS IN C++#include #include using namespace std; int main () {    float ... Read More

Shorthand Array Notation in C for Repeated Values

sudhir sharma
Updated on 07-Aug-2019 14:38:32

179 Views

An array stores number of same data type. For an array there may arise a situation when you need to store 2-3 values that are same i.e. 3,3,3,3 needs to be stored.For this case, the programing language C has made a simple way to create an array with such repeated value to reduce the workload of the programmer.Syntax[startofRepeatingSeq … EndofRepeatingSeq]number Example : For 3 repeated 5 times ; [0 … 4]3Example#include int main() {    int array[10] = {[0 ... 4]3, [6 ... 9]5};    for (int i = 0; i < 10; i++)       printf("%d ", array[i]);    return 0; }Output3 3 3 3 3 0 5 5 5 5

Check If a Binary Tree is BST or Not in C

sudhir sharma
Updated on 07-Aug-2019 14:32:47

408 Views

A binary tree is a tree data structure in which there are two child nodes for each node. The child nodes being two are referred as, left and right child.A BST is a tree structure in which left subtree contains nodes with values lesser than root and right subtree contains nodes with values greater that root.Here, we will check if a binary tree is a BST or not −To check for this we have to check for the BST condition on the binary tree. For a root node check for left child should be less that root, right child should ... Read More

Modified Game of Nim in C

sudhir sharma
Updated on 07-Aug-2019 14:32:16

693 Views

Modified game of Nim is an optimisation games of arrays. This game predicts the winner based on the starting player and optimal moves.Game Logic − In this game, we are given an array{}, that contains elements. There are generally two players that play the game namly player1 and player2. The aim of both is to make sure that all their numbers are removed from the array. Now, player1 has to remove all the numbers that are divisible by 3 and the player2 has to remove all the numbers that are divisible by 5. The aim is to make sure that ... Read More

HTML DOM Console assert Method

AmitDiwan
Updated on 07-Aug-2019 14:26:18

136 Views

The HTML DOM console.assert() method is used to write a message to the console only if the first expression supplied to it is false. These messages are intended for user to see. The expression as well as the displaying message are sent as first and second parameters to the console.assert() method respectively.SyntaxFollowing is the syntax for console.assert() method −console.assert(assertion, msg);Here, assertion is any expression that returns boolean true or false. The msg is a JavaScript string or an object. The assertion should be false to display the msg on console.ExampleLet us see an example for the console.assert() method − ... Read More

Advertisements