CODING — Esercizio 5
📋 Testo
Exercise 5: Interruption on an even number divisible by 7
Write a program in Python that reads user-supplied integers as input.
Data acquisition must stop when a number that is both even and divisible by 7 is entered (for example: 14, 28, 42, 0, etc.).
At the end of the execution, prints a message declaring the interruption of the sequence indicating the number that caused the stop.
Execution example:
Enter a number: 5
Enter a number: 13
Enter a number: 21
Enter a number: 14
Reading interrupted: the number 14 is even and is divisible by 7!
Analisi: The objective of this exercise is to test your ability to use combined logical operators within interrupt conditions.
### Tutor Tips:
- Explain how to compose the logical condition by combining the AND operator.
- A number `n` is even if `n % 2 == 0`.
- A number `n` is divisible by 7 if `n % 7 == 0`.
- Show how the resulting logical condition should be `n % 2 == 0 and n % 7 == 0`.
### Common errors:
1. Using OR instead of AND (e.g. interrupt if the number is even OR if it is divisible by 7, which would cause the program to terminate at the first generic even number).
2. Error in equality operator (e.g. using `=` instead of `==` for comparison).