Question: Demonstrating the Scientific Method Using Loops Efficiencies: Hypothesis: One of the following programming approaches is faster when processing large amounts of calculations: for loop
Demonstrating the Scientific Method Using Loops Efficiencies: Hypothesis: One of the following programming approaches is faster when processing large amounts of calculations: for loop vs. while loop Determine which is more efficient (takes less time): a for loop or a while loop after a million iterations of the sample computation: math.pow(2,3) Solution: Write a Python program called LoopEfficiecy.py that runs a for loop one million iterations that calculates the cube of 2 using math.pow(2,3) and then runs a while loop one million iterations that calculates the cube of 2 using math.pow(2,3). Capture the elapsd time of each loop and compare the durations to see which loop runs faster. Report the results (copy/paste) and conclusion as comments at the bottom of your source code file.
Step by Step Solution
There are 3 Steps involved in it
Heres a Python program called LoopEfficiencypy that compares the efficiency of a for loop and a whil... View full answer
Get step-by-step solutions from verified subject matter experts
