0
def circle_area(radius):
  return 3.14 * radius ** 2
def circle_areaa(radius):
  return 3.14 * radius * radius
print(circle_area(3))
print(circle_areaa(3))

print(3.14 *3 *3)
print(3.14 *9)

28.259999999999998 28.26

I made them print their type. the result was <class 'float'>

  • That's the "magic" of floating point numbers in computers. `3.14` cannot be represented in binary -- it's an infinite repeating decimal -- so you get a close approximation. The more arithmetic you do, the more your round-off errors grow. You just have to be careful. – Tim Roberts Jun 11 '23 at 05:44

0 Answers0