Category: Python Programming Examples

python tutorials and learn python

Created with Sketch.

Python program to copy odd lines of one file to other

  Python program to copy odd lines of one file to other Write a python program to read the contents of a file and copy only the content of odd lines into a new file. Examples: Input : Hello World Python Language Output : Hello Python Input : Python Language Is Easy Output : Python…
Read more

Python program to check if a string contains all unique characters

Python program to check if a string contains all unique characters To implement an algorithm to determine if a string contains all unique characters. Examples: Input : s = “abcd” Output: True “abcd” doesn’t contain any duplicates. Hence the output is True. Input : s = “abbd” Output: False “abbd” contains duplicates. Hence the output…
Read more

Python Program for Legendre\’s Conjecture

Python Program for Legendre\’s Conjecture It says that there is always one prime number between any two consecutive natural number\’s(n = 1, 2, 3, 4, 5, …) square. This is called Legendre\’s Conjecture. Conjecture: A conjecture is a proposition or conclusion based upon incompleate information to which no proof has been found i.e it has…
Read more

Python Program for Triangular Matchstick Number

Python Program for Triangular Matchstick Number Introduction Triangular matchstick numbers are a sequence of numbers that represent a triangular pattern formed using matchsticks. Each number in the sequence corresponds to the total number of matchsticks required to form a triangle with a certain number of layers. The pattern resembles a triangle made of matchsticks, and…
Read more

Python Program for Number of solutions to Modular Equations

Python Program for Number of solutions to Modular Equations Given A and B, the task is to find the number of possible values that X can take such that the given modular equation (A mod X) = B holds good. Here, X is also called a solution of the modular equation. Examples: Input : A…
Read more

Check whether a number has consecutive 0’s in the given base or not

Checking for Consecutive Zeros in a Number: Implementation in Python The problem involves determining whether a given number has consecutive zeros in its representation for a given base. In this blog post, we will implement this solution using Python. The Python program will not only provide the implementation but also offer detailed explanations, the logic…
Read more

Python program to convert floating to binary

Python program to convert floating to binary Python doesn’t provide any inbuilt method to easily convert floating point decimal numbers to binary number. So, Let’s do this manually. Approach : To convert a floating point decimal number into binary, first convert the integer part into binary form and then fractional part into binary form and…
Read more

Python program to convert float decimal to Octal number

Python Program to Convert Float Decimal to Octal Number Introduction In this blog post, we will explore the concept of converting a floating-point decimal number to its octal representation. Octal (base-8) is a numeral system that uses eight digits (0-7). We will discuss the algorithm to achieve this conversion and provide a step-by-step guide. Additionally,…
Read more

Python Program for Check if all digits of a number divide it

Python Program to Check if All Digits of a Number Divide It Introduction In this blog post, we will discuss and implement a Python program to check if all digits of a given number divide the number evenly. The program will take an integer as input and determine whether each digit of the number is…
Read more

Python Program for Find sum of even factors of a number

Python Program to Find the Sum of Even Factors of a Number Introduction Factors of a number are the positive integers that divide the number completely. In this Python program, we will focus on finding the sum of even factors of a given number. The program will take a positive integer as input, calculate its…
Read more