Python program to print numbers divisible by the given number

Veröffentlicht am: 02 April 2024
auf dem Kanal: Py Code Labs
518
17

Python Program to Print All Numbers in a Range Divisible by a Given Number
This is a Python Program to print all numbers in a range divisible by a given number.

Problem Description
The program prints all numbers in a range divisible by a given number.

Problem Solution
1. Take in the upper range and lower range limit from the user.
2. Take in the number to be divided by the user.
3. Using a for loop, print all the factors which is divisible by the number.
4. Exit.
Program/Source Code
Here is the source code of the Python Program to print all numbers in a range divisible by a given number. The program output is also shown below.


lower=int(input("Enter lower range limit:"))
upper=int(input("Enter upper range limit:"))
n=int(input("Enter the number to be divided by:"))
for i in range(lower,upper+1):
if(i%n==0):
print(i)

Program Explanation

1. The user must enter the upper range limit and the lower range limit.
2. Then the user must enter the number to be divided from the user.
3. The value of i ranges from the lower limit to the upper limit.
4. Whenever the remainder of the number divided by i is equal to 0, i is printed.

Runtime Test Cases

Enter lower range limit:50
Enter upper range limit:100
Enter the number to be divided by:7
56
63
70
77
84
91
98




#python #ballpython #ballpythonsofinstagram #ballpythons #royalpython #pythonsofinstagram #pythons #pythonregius #ballpythonmorphs #montypython #ballpythonsofig #ballpythonbreeder #pythonprogramming #reticulatedpython #ballpythonmorph #pythonbag #carpetpython #burmesepython #greentreepython #pythoncode #pythonskin #royalpythonsofinstagram #royalpythons #pythonleather #ballpythonbreeding #pythonsofig #python3 #pastelballpython #ballpythonlove #bananaballpython #bloodpython #pythonbracelet #montypythonandtheholygrail #ballpythonofinstagram #gelangpython #babyballpython #piedballpython #ballpythonmorphsofinstagram #pythonbags #pythonshoes #pycodelabs


Auf dieser Seite können Sie das Online-Video Python program to print numbers divisible by the given number mit der Dauer online in guter Qualität ansehen, das der Benutzer Py Code Labs 02 April 2024 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 518 Mal angesehen und es wurde von 17 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!