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: Python File Program Count Characters in Text File »

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: Python Exception Handling FileNotFoundError »

Loading

Python Text File Read and Show File Contents

  Task: Python Text File Read and Show File. This Python programming tutorial will use open(), read() and print() functions to read and display the whole contents of a text file on the drive D. First of all, we assume that the text file mytext.txt already exist on the D drive. Otherwise you can use… Read More: Python Text File Read and Show File Contents »

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: Python file program read numbers write squares »

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: Python Local and Global Variables With Example Programs »

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: Python Pounds to Kilograms Conversion Program »

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: Python GCD Program by Successive Division »

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: Python GCD code using math.gcd() Function »

Loading

Python GCD Program with for statement

Python GCD Program with for statement – This Programming tutorial will explain a simple logic and Python code to find GCD. A simple for loop statement is used to calculate Greatest common Divisor of the two given numbers. The Source code and Output of Python GCD Program with for statement # Write a Python program… Read More: Python GCD Program with for statement »

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: Python Swap Two Variables Without Temp Variable »

Loading