Session Ready
Exercise

Importing a module

You now know that any .py Python file can act as a module. A module is a Python file that can be imported into a Python terminal or script file. The first place Python will look for a module file is the current working directory. This means that any .py file you write can be used by other .py files in the same directory.

In your terminal there is a file called pi.py. Use tools like nano, vim, vi, less, more, or emacs to inspect the file. It defines a single function compute_pi(). This function takes a single integer argument, n_iters the number of iterations, larger values means you will get a more accurate estimate of \(pi\) but the computation will take longer.


Your job is to launch the Python interpreter by running python on the command line, import the pi module and call the compute_pi() function. With input n_iters = 1000 which value best matches what compute_pi() returned?

Instructions
50 XP
Possible Answers