Posts From Python Programming Examples

Python Increment Operation

Python Increment Operation

How do you perform a Python increment operation? If you’re coming from a language like C++ or Java, you may want to try extending a similar increment functionality to Python also. But, as we will see in this article, this is not quite the same. Let’s look at how we can try to use similar […]

Python Factorial

Python Factorial Examples

In this article, we’ll look at how we can calculate the Python factorial using different approaches. The Python Factorial function The Python factorial function factorial(n) is defined for a whole number n. This computes the product of all terms from n to 1. factorial(0) is taken to be 1. So, the function is: Therefore, factorial(4) […]

Python Print Without Newline

There are different ways through which we can print to the console without a newline. Let’s quickly go through some of these methods. 1. Using print() We can use the print() function to achieve this, by setting the end (ending character) keyword argument appropriately. By default, this is a newline character (\n). So, we must […]

Python – Catch Multiple Exceptions

Python always operates on an Exception based model. That is, any errors during the program execution are passed as Exceptions and returned to the programmer, which may be handled accordingly using Exception Handling techniques. Sometimes, it is possible that a process raises more than one possible exception, depending on the flow of control. Thus, we […]

Python – Check if Variable is a String

Since Python does not support static type checking (i.e type checking at compile type), if you ever want to check if a Python variable or object is a String or not; we need to use certain methods. Let us understand some of the ways of checking for a string type object. 1. Using isinstance() method […]

Calculator Program in Python

Python programming is a great tool to evaluate and make manipulations. In this article, We will be learning a simple command-line calculator program in Python 3. We’ll be using mathematical operators, Conditional statements, functions and handle user input to make our calculator. Prerequisites The system should have Python 3 installed on the local computer and have a […]