Question: Can someone help me convert this C++ code to python? The rainfall_data.txt file contains the following information: 0.21 0.00 T 0.00 0.78 0.08 0.00 2.54
Can someone help me convert this C++ code to python? The rainfall_data.txt file contains the following information:
0.21 0.00 T 0.00 0.78 0.08 0.00 2.54 0.00 0.05 0.45
And the output should be the following:
Average = 2.33 days
Total rainfall: 4.12 inches
#include
while(inFileStr >> value) { if(value!="T") myArray[i]=stof(value); else myArray[i] = 0.01; i++; } for(int p=0; p<=i; p++) { sum = sum+myArray[p]; } int l=0; for(int k=1; k<=i; k++) { if(myArray[k]<0.10) { l++; } else { avg=avg+l; z=z+1; l=0; } } cout<<"Average = "<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
