GitHub Repository Submission

When using GitHub mode, paste your repository URL below and click Save URL to store it. The saved URL will be automatically included with every message you send until you choose to clear it. Learn more

Your GitHub repository URL is saved. LSBot will automatically fetch your latest code from this repository for each message. To change the URL, clear it first and save a new one.

Exercise 19

The following function returns a list of the remainders of dividing the numbers in numbers by 5:

def remainders_5(numbers):
    return [number % 5 for number in numbers]

Use this function to determine which of the following lists do not contain any numbers that are divisible by 5:

numbers_1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
numbers_2 = [1, 2, 3, 4, 6, 7, 8, 9]
numbers_3 = [0, 5, 10]
numbers_4 = []

Note: when working with integers, a value of 0 is "falsy"; all other integers are "truthy".

Solution

print(all(remainders_5(numbers_1)))     # False
print(all(remainders_5(numbers_2)))     # True
print(all(remainders_5(numbers_3)))     # False
print(all(remainders_5(numbers_4)))     # True

remainders_5 is similar to remainders_3 in the previous exercise in that it returns a list of integers. In this list, a value of 0 means the corresponding number is divisible by 5, while a non-zero value means the number is not divisible by 5. Since 0 is falsy and the other integers are truthy, we can use all to determine whether all of the numbers are not divisible by 5.

Video Walkthrough

Hi! I'm LSBot. I can help you think through the selected exercise by giving you hints and guidance without revealing the solution. Your code from the editor will be automatically detected. Want to know more? Refer to the LSBot User Guide .

Detected solution
Loading...

Submit your solution for LSBot review.

Hi! I'm LSBot. Your code from the editor will be automatically detected. I'll review your solution and provide feedback to help you improve. Ask questions about your solution or request a comprehensive code review. Want to know more? Refer to the LSBot User Guide .

Detected solution
Loading...