From 8c1f70dc5d908e6d34adab29f2569b8e19be77b3 Mon Sep 17 00:00:00 2001 From: Stefano Agnelli Date: Wed, 1 May 2024 21:56:03 +0200 Subject: [PATCH] added solution m1/008 --- projects/008-dog-years/python/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/projects/008-dog-years/python/main.py b/projects/008-dog-years/python/main.py index e69de29..a83727b 100644 --- a/projects/008-dog-years/python/main.py +++ b/projects/008-dog-years/python/main.py @@ -0,0 +1,11 @@ + +human_y = int(input('Insert human years:')) + +if 0 <= human_y <= 2: # condizione 1 + dog_y = human_y * 10.5 + print(f'{human_y} human years = {dog_y:.1f} dog years') +elif human_y > 2: # condizione 2 (else if) + dog_y = (human_y - 2) * 4 + 21 + print(f'{human_y} human years = {dog_y:.1f} dog years') +else: # se nessuna condizione รจ rispettata + print('Negative values are not accepted')