in Python create a code that loop from 1 to 100 and print if the number is div by 2
- User
in Python create a code that loop from 1 to 100 and print if the number is div by 2
Assistant
Divisibility by 2 Checker
Below is a Python code snippet that loops through numbers 1 to 100 and checks if each number is divisible by 2.
def check_divisibility_by_2(start=1, end=100): """ Loop through numbers from start to end and print if each number is divisible by 2. Args: start (int, optional): The starting number. Defaults to 1. end (int, optional): The ending number. Defaults to 100. """ for num in range(start, end + 1): if num % 2 == 0: print(f"{num} is divisible by 2") else: print(f"{num} is not divisible by 2") # Example usage if __name__ == "__main__": check_divisibility_by_2()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.