Print Fibonacci Series in C++

A “Fibonacci series” is a series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 1, 1, 2, 3, 5, 8, etc. To print a Fibonacci series in C++, you have to ask the user to enter the total number of terms that he/she want to print fibonacci series upto the required number.

Continue reading

Comparison and Boolean Ops in Python

Python comparisons are unusual in that chaining comparisons is allowed, and works reasonably. Chained comparisons translate to a series of anded terms, repeating the middle. For instance, a < b == c <= d is interpreted as a < b and b == c and c <= d. The only other note is that the middle expression (4 in the below example) is evaluated only once. For a constant, this doesn’t matter, but it will make a difference for expressions which have a side-effect. Note that this does not always have the desired effect. For instance, 3 != 2 != 3 is true, which might not be what you wanted.

Continue reading