..

Applying Knowledge - Class 3

Write a Python program to solve the following problem:

The program must receive an integer typed by the user and display a message:

  • If the number typed by the user is divisible by both three (3) and five (5) simultaneously, the message will display: The number is divisible by 3 and 5.
  • If the number typed by the user is not divisible by both three (3) and five (5) at the same time, the message will display: The number is not divisible by 3 and 5.

Ensure to display the messages exactly as indicated above.

Input:

  • An integer number.

Output:

  1. If the number typed by the user is divisible by 3 and 5 simultaneously, display the message: The number is divisible by 3 and 5.
  2. If the number typed by the user is not divisible by 3 and 5 at the same time, print out the message: The number is not divisible by 3 and 5.

Sample Inputs/Outputs:

foo@bar:~$ py baz.py
15
The number is divisible by 3 and 5
foo@bar:~$
foo@bar:~$ py baz.py 
25
The number is not divisible by 3 and 5
foo@bar:~$

SOLUTION:

x = int(input())
if x%15 == 0:
    print('O número é divisível por 3 e 5')
else:
    print('O número não é divisível por 3 e 5')

for fun:

(lambda x: print('O número é divisível por 3 e 5' if x%15 == 0 else 'O número não é divisível por 3 e 5'))(int(input()))