M.Sc Python Programming Assignment 3

M.Sc Python Programming Assignments

Assignment 3

Question:

Write a program which will find all such numbers which are divisible by 7

Code:

				
					start = int(input("Enter the starting number: "))
end = int(input("Enter the ending number: "))

divisible_by_7 = []

for number in range(start, end + 1):
    if number % 7 == 0:
        divisible_by_7.append(number)

print("Numbers divisible by 7:")
print(divisible_by_7)

				
			

Output:

				
					Enter the starting number: 32
Enter the ending number: 44
Numbers divisible by 7:
[35, 42]

				
			
Tech Amplifier Final Logo