Posts From Python Programming Examples

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 […]

Python User Input from Keyboard – input() function

Python user input from the keyboard can be read using the input() built-in function. The input from the user is read as a string and can be assigned to a variable. After entering the value from the keyboard, we have to press the “Enter” button. Then the input() function reads the value entered by the […]