Python Exercise: Find numbers which are divisible by 7 and multiple of 5 between a range
Python Conditional: Exercise-1 with Solution
Write a Python program to find those numbers which are divisible by 7 and multiples of 5, between 1500 and 2700 (both included).
# Create an empty list to store numbers that meet the given conditions nl =  # Iterate through numbers from 1500 to 2700 (inclusive) for x in range(1500, 2701): # Check if the number is divisible by 7 and 5 without any remainder if (x % 7 == 0) and (x % 5 == 0): # If the conditions are met, convert the number to a string and append it to the list nl.append(str(x)) # Join the numbers in the list with a comma and print the result print(','.join(nl))
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join