Write A Python Program To Find Those Numbers Which Are Divisible By 7 And Multiple Of 5

Hi Guys, welcome to my blog in this article you will learn about how to Write A Python Program To Find Those Numbers Which Are Divisible By 7 And Multiple Of 5

 

Title : 

Write A Python Program To Find Those Numbers Which Are Divisible By 7 And Multiple Of 5


write a python program to find those numbers which are divisible by 7 and multiple of 5



 

Description : 

In this blog, let's explore a Python program that identifies numbers that are both divisible by 7 and multiples of 5. To solve this problem, we need to identify numbers that satisfy two conditions: being divisible by 7 and also being a multiple of 5. This means that when we divide these numbers by 7, there should be no remainder, and when we divide them by 5, the remainder should also be zero.

 In this program, I define the function find_numbers(), which takes the starting and ending numbers as input. The function iterates over the range of numbers between the starting and ending points. For each number, it checks if it's divisible by 7 and a multiple of 5 using the modulo operator. If the number satisfies both conditions, it's added to the result list, the list is finally returned


    
def find_numbers(start, end):
    result = []
    for num in range(start, end + 1):
        if num % 7 == 0 and num % 5 == 0:
            result.append(num)
    return result



    


Finally, in the main program two variables start and end, the program prompts the user to enter the starting and ending numbers, calls the find_numbers function, and displays the resulting list of numbers.


    
start_num = int(input("Enter the starting number: "))
end_num = int(input("Enter the ending number: "))

numbers = find_numbers(start_num, end_num)
print("Numbers divisible by 7 and multiples of 5:")
print(numbers)



    



    

    




Complete Python Code : 


    
def find_numbers(start, end):
    result = []
    for num in range(start, end + 1):
        if num % 7 == 0 and num % 5 == 0:
            result.append(num)
    return result

start_num = int(input("Enter the starting number: "))
end_num = int(input("Enter the ending number: "))

numbers = find_numbers(start_num, end_num)
print("Numbers divisible by 7 and multiples of 5:")
print(numbers)



    

 

 

Output : 


    
Enter the starting number: 10
Enter the ending number: 50
Numbers divisible by 7 and multiples of 5:
[35]




    

 

Output : 


    
Enter the starting number: 100
Enter the ending number: 150
Numbers divisible by 7 and multiples of 5:
[105, 140]



    



Conclusion :

In this blog, we explored a Python program to find numbers divisible by 7 and multiples of 5. we examined the problem, developed an algorithm, presented the final program. This program offers a practical solution for identifying numbers that satisfy specific divisibility and multiplication conditions, potentially useful in various mathematical and programming scenarios. I hope this blog has been helpful in enhancing your Python programming skills. Comment it down below if you have any suggestions to improve the above Python program

Post a Comment

0 Comments