diff --git a/docs/index.md b/docs/index.md index b867c972b4b48..de1429cd2ac19 100644 --- a/docs/index.md +++ b/docs/index.md @@ -44,6 +44,9 @@ launching applications). For example, ./bin/run-example SparkPi 10 +The above example runs the Monte Carlo method to estimate the value of Pi. The arguement passed +(i.e. 10 in this case) is the number of partitions in the RDD. + You can also run Spark interactively through a modified version of the Scala shell. This is a great way to learn the framework. diff --git a/examples/src/main/python/pi.py b/examples/src/main/python/pi.py index 5839cc2874956..0c9aedd52209c 100755 --- a/examples/src/main/python/pi.py +++ b/examples/src/main/python/pi.py @@ -27,12 +27,16 @@ if __name__ == "__main__": """ Usage: pi [partitions] + + Monte Carlo method is used to estimate Pi in the below example. """ spark = SparkSession\ .builder\ .appName("PythonPi")\ .getOrCreate() + # If no arguments are passed(i.e. `len(sys.argv) < = 1` ) + # while calling this script, the default value assigned is 2 partitions = int(sys.argv[1]) if len(sys.argv) > 1 else 2 n = 100000 * partitions