Check if a List is sorted in Python

In the previous article, we saw how we can obtain a count of all the distinct elements of a list. Now we will look at how we can implement a program to Check if a List is sorted in Python. We need to check if the list is in non-decreasing order, as in every element … Read more

Returning multiple Variables in Python

In the previous article saw how parameters are passed and handled in Python, now we will look at how we can return multiple variables in Python. Here is an example program that returns two values: When we call the function we receive the two values from add_multiply, later the program prints out the value of … Read more

Global Variables in Python

In the previous article we looked at how we can return multiple variables in Python. Now let us discuss about Global Variables in Python, Global variables are the variables declared outside of functions and classes and that are accessible throughout the entire program. Here in this article we will mainly look at the use of … Read more

Variable Length Arguments in Python

In the previous article we have discussed keyword arguments, now we will look at another type of argument that can be provided to functions: Variable length arguments. Many times we want a functionality to be implemented for various different inputs. If we pass two, then we want sum of two variables. We want a sum … Read more

Applications of Functions in Python

In the previous article we had a look at the basics of Functions, now let us look at the various areas within a program’s code or script that a Function would come in handy. Functions are an essential part of most programming languages. Functions are reusable pieces of code that can be called using a … Read more

All Divisors of a Number in Python

In the previous article, we saw how we can determine a Prime Number using Python logic and syntax. In this article we will explore All Divisors of a Number in Python. Imagine that we have a tower of height 12 using equal size blocks, we need to find the size of all the blocks that … Read more

Optimized solutions in Python for All Divisors and Prime Number

In the previous article we explored programs for obtaining all divisors of a given number. Let us see the ways in which we can discuss optimize the programs in the previous article as well as the program for Prime Numbers. Optimizing programs in recent usage or legacy code is important as we gain new knowledge … Read more

Fibonacci Numbers in Python

In the previous article we explored the LCM Concept and two different ways we can obtain them, now we will look at what the Fibonacci numbers are and how they can be obtained or the way in which Fibonacci Numbers in Python are implemented. Let us look at a problem involving Fibonacci numbers: There are … Read more

LCM of two Numbers in Python

In the previous article we explored about GCD and it’s implementation in Python. Now let us explore the concept of LCM and how we can arrive at the LCM of two Numbers in Python. Before we delve further into Python let us look at a problem which can further/or revise our understanding of LCM. We … Read more