Blog

python tutorials and learn python

Created with Sketch.

Python Program to Find Armstrong Number between an Interval

Python Program to Find Armstrong Number between an Interval We have already read the concept of Armstrong numbers in the previous program. Here, we print the Armstrong numbers within a specific given interval. See this example: lower = int(input(“Enter lower range: “)) upper = int(input(“Enter upper range: “)) for num in range(lower,upper + 1):    sum = 0    temp = num    while temp > 0:        digit = temp % 10        sum += digit ** 3        temp //= 10        if num == sum:             print(num) lower = int(input(“Enter lower range: “))<br /> upper…
Read more

Python Program to Check Armstrong Number

Python Program to Check Armstrong Number Armstrong number: A number is called Armstrong number if it is equal to the sum of the cubes of its own digits. For example: 153 is an Armstrong number since 153 = 1*1*1 + 5*5*5 + 3*3*3. The Armstrong number is also known as narcissistic number. See this example:…
Read more

Python Program to Print all Prime Numbers between an Interval

Python Program to Print all Prime Numbers between an Interval We have already read the concept of prime numbers in the previous program. Here, we are going to print the prime numbers between given interval. See this example: #Take the input from the user:  lower = int(input(“Enter lower range: “)) upper = int(input(“Enter upper range: “)) for num in range(lower,upper + 1):    if num > 1:        for i in range(2,num):            if (num % i) == 0:                break        else:            print(num) #Take the input from the user:<br />…
Read more

Python Program to Check Prime Number

Python Program to Check Prime Number Prime numbers: A prime number is a natural number greater than 1 and having no positive divisor other than 1 and itself. For example: 3, 7, 11 etc are prime numbers. Composite number: Other natural numbers that are not prime numbers are called composite numbers. For example: 4, 6,…
Read more

Python Program to Check if a Number is Odd or Even

Python Program to Check if a Number is Odd or Even Odd and Even numbers: If you divide a number by 2 and it gives a remainder of 0 then it is known as even number, otherwise an odd number. Even number examples: 2, 4, 6, 8, 10, etc. Odd number examples:1, 3, 5, 7,…
Read more