From 4d2b40244ade4e31151a7737cfc852a3fc6caabe Mon Sep 17 00:00:00 2001
From: fbury <florian.bury@cern.ch>
Date: Mon, 11 Oct 2021 08:51:31 +0200
Subject: [PATCH] Few corrections on chapter 4

---
 Chapter_4/ex3.py | 9 ++++-----
 Chapter_4/ex4.py | 1 +
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/Chapter_4/ex3.py b/Chapter_4/ex3.py
index f554caf..2d9bbcf 100644
--- a/Chapter_4/ex3.py
+++ b/Chapter_4/ex3.py
@@ -1,14 +1,13 @@
 
 
 def is_perfect(number):
-    if type(number)==float:
-        print("Warning, {0} is a float. The function will consider it to be {1} instead.".format(number,int(number+0.5)))
-        number = int(number+0.5)
-    elif type(number) != int:
+    if isinstance(number,float):
+        print("Warning, {0} is a float. The function will consider it to be {1} instead.".format(number,round(number)))
+        number = round(number)
+    elif not isinstance(number,int):
         print("Error, cannot understand the user input : {0}".format(number))
         return False
 
-
     sum_div = 0
     for div in range(1,number+1):
         if number%div == 0:
diff --git a/Chapter_4/ex4.py b/Chapter_4/ex4.py
index 673ecfc..97e062f 100644
--- a/Chapter_4/ex4.py
+++ b/Chapter_4/ex4.py
@@ -54,3 +54,4 @@ def date_format(date, dformat = "dd/mm"):
         return ""
 
     return french_date(day, month)
+
-- 
GitLab