In the recent python activity held in TP, I got 2 tasks. The first one is to calculate volumes of different shapes according to people’s choice.
After one hour of struggling, I finally figured it out with the help of teacher.(I’m still a beginner (: ) And the program looks like this:
1 | import math |
As for the second task, I was asked to write a program to use the Monte Carlo method to calculate the area of any irregular shape. However, because I was still a rookie, my teacher eased the task and I only had to calculate pi using this method.
The final result looks pretty simple, but took me a while to figure out):
1 | import random |
It turns out that the atmosphere does helps with your study!