Category Archives: Python Programming Language

Python File Program Count Characters in Text File

Task: Write a Python File Program To Count Characters in Text File. This Python Programming tutorial will explain a simple logic to show number of characters in a text file. The Python programming language provides open() function. We will use open() function to open an existing file in read mode. As we know that the… Read More »

Loading

Python Exception Handling FileNotFoundError

Task: Python Exception Handling FileNotFoundError –  If the user enters a wrong name or path for the file, this program will handle it gracefully by showing a simple and easy to understand error message. How To Handle FileNotFound Exception in Python? We will use try-except block to handle FileNotFound exception. Note that the try-block will… Read More »

Loading

Python file program read numbers write squares

Task: Write a Python file program read numbers write squares. This Python programming tutorial will explain the Python program with the following statement: Write a Python program to open an existing text file called “fnumbers.txt” on D drive. It will read each number and calculate its square. Then the program will write the square in… Read More »

Loading

Python Local and Global Variables With Example Programs

Task: Python Local and Global Variables With Example Programs – This Python programming tutorial explains the use of Python Local and Global Variables With Example Programs. Using Local and Global Variables in Python Code Local Variables in Python What is a Local Variable in Python? In Python any variable which is defined inside a function… Read More »

Loading

Python Pounds to Kilograms Conversion Program

Topic: Python Pounds to Kilograms Conversion Program – This Python Programming Tutorial will explain the Python code to input weight in pounds and convert into kilograms. The Formula for the Pounds to Kilograms Conversion e will use the following formula to convert the given pounds in kilograms. 1 Pound = 0.453592 Kilograms or 1 lb… Read More »

Loading

Python GCD Program by Successive Division

Python GCD Program by Successive Division – This Python Programming tutorial will explain the Pthon code to find Greatest Common divisor or HCF. The HCF stands for Highest common factor which is a second name of GCD. This progrram will calculate GCD of two positive inetegers using Improved version of Euclid’s algorithm – Succesive division… Read More »

Loading

Python GCD code using math.gcd() Function

Python GCD code using math.gcd() function – This Python programming tutorial explains the method of finding GCD of two numbers using math module’s gcd() function. What is Python gcd() functin of math module The math.gcd(a,b) function return the greatest common divisor of the integers a and b. Therefore, gcd(a,b) function will calculate the largest positive… Read More »

Loading

Python Swap Two Variables Without Temp Variable

Python Swap Two Variables Without Third – This Python programmin tutorial explains the Python Swap Two Vaibles Without Third Variable progrm.   # Write a Python program to swap # the values of two variables without # using a third variable # Author: www.EasyCodeBook.com (c) num1= int(input(‘Enter The value of num1 Variable:’)) num2= int(input(‘Enter The… Read More »

Loading