Sunday, June 28, 2020

Limits of recursive functions

The biggest drawback of recursive functions is that it has a limit to the maximum number of recursive calls it can have( also called the maximum possible depth of recursion).


This is best explained by a simple recursive function shown below which prints the sum of two numbers.


As you can see, we cannot add a number greater than 994 to 5 using recursion because in doing so the maximum recursion depth, which is only 1000 in case of Python gets exceeded. 

The number of recursions( iterations) cannot be greater than 1000 in Python.

Thursday, June 18, 2020

A simple Prolog program: facts.pl

Following are some screenshots of a simple Prolog program, that has its knowledge base file, named ' facts.pl ' and the various questions asked to it; and the  answers given by the Prolog engine based on the facts mentioned in the KB (using the SWI Prolog compiler software):




Following is how to compile the file


Following is Error because file was not re-compiled after edit


Following is after re-compilation after edit



Prolog tutorial: From installation to coding

Thursday, June 11, 2020

How to print a float only upto two decimal places in Python

USE str.format() TO PRINT A FLOAT WITH TWO DECIMAL PLACES

Call str.format(number) with "{:.2f}" as str and a float as number to return a string representation of the number with two decimal places. Call print(string) with the formatted float-string as string to print the float.
a_float = 3.14159
formatted_float = "{:.2f}".format(a_float)

print(formatted_float)

OUTPUT
3.14

source: https://kite.com/python/answers/how-to-print-a-float-with-two-decimal-places-in-python#:~:text=Use%20str.&text=2f%7D%22%20as%20str%20and%20a,string%20to%20print%20the%20float.

Tuesday, June 9, 2020

How to enable Virtualization VT-x in BIOS in Windows 10

Nice youtube video
https://www.youtube.com/watch?v=MOuTxfzCvMY

It is essential to do following to things to create a AVD Emulator in your Android Studio:


  1. Di-activate  Hyper-V or the hypervisor platform in "activate/deactivate your Windows functions" in Windows 10 PC
  2. Activate virtualization in bios


Before:

After:


इश्क में ग़ैरत-ए-जज़्बात ने रोने ना दिया - सुदर्शन फ़ाकिर

 इश्क में ग़ैरत-ए-जज़्बात ने रोने ना दिया वरना क्या बात थी किस बात ने रोने ना दिया आप कहते थे कि रोने से ना बदलेंगे नसीब उमर भर आप की इस बात...