In chapter 4 - Executable cell N.2 gives pi value of 0

The code prints the following:
“Approximate value of pi is 0”

proposed solution:
change lines 7,8 of code:

points_inside_circle = 0
points_inside_square = 0


points_inside_circle = 0.0
points_inside_square = 0.0

after the change the code outputs a reasonable approximation of pi:
“Approximate value of pi is 3.164”

Instead of declaring the variables “points_inside_circle” and “points_inside_square” as int (integer), declare them as double

how do i declate a variable with a specific type in python?

@lior @chiragmagnani1004
Let us look into this and get back to you.

@lior when you initialize a variable in Python, the type is automatically “guessed” on the value you assign to it. What you have basically done is to change the type of those variables from integer to float.

This has been updated according to your suggestions. Thanks again.

This topic was automatically closed after 9 hours. New replies are no longer allowed.